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

Instruction

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

Here is a syntax reminder:

SELECT
  Id,
  Quantity,
  ChangedDate,
  SUM(Quantity) OVER(ORDER BY
    ChangedDate ASC ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) AS SumQuantity
FROM StockChange

Exercise

For each order, show its Id, the PlacedDate, and a third column, which will count the number of orders up to the current order, when sorted by PlacedDate. Name this column OrderNumber.

Stuck? Here's a hint!

Sort the rows by PlacedDate inside the OVER() parentheses. Then introduce the keyword ROWS and use the BETWEEN ... AND ... construction.