Introduction
Quick refresher
PARTITION BY ORDER BY with ranking
PARTITION BY ORDER BY with window frames
14. Practice 1
PARTITION BY ORDER BY with analytical functions
Revision

Instruction

Fine! By the same token, you can use PARTITION BY ORDER BY with any other window frame. Shall we practice a bit more?

Exercise

Take sales from the period between August 1 and August 10, 2016. For each row, show the following information: store_id, day, number of transactions and the average number of transactions in the respective store in the window frame starting 2 days before and ending 2 days later with respect to the current row.

Stuck? Here's a hint!

Use ROWS BETWEEN 2 PRECEDING AND 2 FOLLOWING.

Console

Code editor

Result

TableConsole