Skip to content
Bugwise
Menu

Window function

Also called: ROW_NUMBER, LAG, OVER clause, Analytic function

An SQL function that computes a value for each row while looking at a group of rows, without collapsing them.

Definition

ROW_NUMBER finds the latest row per group, LAG compares a row with the previous one, and SUM … OVER gives running totals. Testers use them to check the latest status of every order, the first order of every customer, or steps that happen out of order.

In practice

ROW_NUMBER() OVER (PARTITION BY order_id ORDER BY changed_at DESC) = 1 keeps each order's latest status.

Learn it in context

Lessons that use this term.

Related terms

Esc

Type to search the whole site.