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

Instruction

Excellent! Let's review what we've learned in this part:

  • You can define a window frame within OVER(...). The syntax is:
    [ROWS|RANGE] <WindowFrameDefinition>
  • ROWS always treats rows individually (like the ROW_NUMBER() function)
  • RANGE always adds rows that share the same value in the column we order by (like the RANK() function).
  • The <WindowFrameDefinition> is defined by BETWEEN <LowerBound> AND <UpperBound>, where the bounds are defined using:
    • UNBOUNDED PRECEDING,
    • n PRECEDING (ROWS only),
    • CURRENT ROW,
    • n FOLLOWING (ROWS only),
    • UNBOUNDED FOLLOWING
  • Remember that if <UpperBound> is equal to CURRENT ROW, you can use abbreviations and omit the <UpperBound>
    • [ROWS|RANGE] UNBOUNDED PRECEDING
    • [ROWS] n PRECEDING
    • [ROWS|RANGE] CURRENT ROW

So, are you ready for a short quiz?

Exercise

Click Next exercise to continue.