Introduction
ROWS
RANGE
Default window frame
19. Default window frame - without ORDER BY
Revision

Instruction

Perfect! You may wonder what the default window frame is when it's not explicitly specified. This may differ between databases, but the most typical rule is as follows:

If you don't specify an ORDER BY clause within OVER(...), the whole partition of rows will be used as the window frame.

If you do specify an ORDER BY clause within OVER(...), the database will assume RANGE UNBOUNDED PRECEDING as the window frame. Let's check both of these cases in exercises.

Exercise

We'll start with not specifying an ORDER BY clause within OVER(...).

For each single order, show its id, date when it was placed, the total price and the sum of all total prices.

Note that the SUM computes the sum of all prices in the table, even though you did not specify the window frame.

Console

Code editor

Result

TableConsole