thinQmaster Virtual testing partner Adaptive practice exams that find your weak spots and drill them. Every answer explained. From $69
Enroll

thinQmaster

Find your exam

Five questions free, before you decide.

Step 1 · choose a vendor

In one of our camps? Your practice exams come with the tuition — they are on your study page already.

Data & Analytics · Advanced

Window Frame

The subset of rows within a partition that a window function considers, set with ROWS or RANGE BETWEEN.

Definition

ROWS BETWEEN 6 PRECEDING AND CURRENT ROW gives a 7-row moving window. When ORDER BY is present without an explicit frame, the default is RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW, which includes ties (peer rows). ROWS counts physical rows, while RANGE uses value ranges.

Example

AVG(Sales) OVER (ORDER BY Day ROWS BETWEEN 6 PRECEDING AND CURRENT ROW)

Exam tip

Running totals that jump on duplicate dates are caused by the default RANGE frame; specify ROWS to fix them.

Related terms