Instruction
Fine! If our window frame has CURRENT ROW as one of the boundaries, we can also use some abbreviated syntax to make things easier:
ROWS UNBOUNDED PRECEDINGmeansBETWEEN UNBOUNDED PRECEDING AND CURRENT ROWROWS n PRECEDINGmeansBETWEEN n PRECEDING AND CURRENT ROWROWS CURRENT ROWmeansBETWEEN CURRENT ROW AND CURRENT ROW
The same rules applies for FOLLOWING. As a way of example, the following query:
SELECT id, name, introduced, COUNT(id) OVER(ORDER BY introduced ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) FROM product;
Can be rewritten to:
SELECT id, name, introduced, COUNT(id) OVER(ORDER BY introduced ROWS UNBOUNDED PRECEDING) FROM product;
Exercise
You will now have a chance to practice abbreviations. Pick those stock changes which refer to product_id = 3. For each of them, show the id, changed date, quantity, and the running total, indicating the current stock status. Sort the rows by the changed date in the ascending order.
Stuck? Here's a hint!
Use the abbreviated form: ROWS UNBOUNDED PRECEDING.



