Introduction
ROWS
7. First exercise
RANGE
Default window frame
Revision

Instruction

Okay! It's your turn to write a query!

Here is a syntax reminder:

SELECT
id,
quantity,
changed,
SUM(quantity) OVER(ORDER BY
changed ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
FROM stock_change

Exercise

For each order, show its id, the placed date, and the third column which will count the number of orders up to the current order when sorted by the placed date.

Stuck? Here's a hint!

Within the parentheses of OVER(...), sort the rows by the placed date. Then, introduce the keyword ROWS and use the BETWEEN ... AND ... construction.

Code editor

TableConsole