Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
ROWS
RANGE
15. Boundaries with RANGE
Default window frame
Summary

Instruction

Great! The window frame of RANGE is defined just like the window frame of ROWS: with BETWEEN ... AND ... or the abbreviated version.

You can use RANGE UNBOUNDED PRECEDING and RANGE BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING, as well as RANGE CURRENT ROW. Support for n PRECEDING and n FOLLOWING with RANGE was added to PostgreSQL 11. Prior to version 11, using n PRECEDING and n FOLLOWING with RANGE was not allowed in PostgreSQL.

Exercise

For each stock_change with product_id = 7, show its id, quantity, changed date and another column to count the number of stock changes with product_id = 7 on that particular date.

Stuck? Here's a hint!

Use the abbreviated version: RANGE CURRENT ROW.