Business analysis glossary
Window Function
What it is
A window function calculates a value across a set of rows related to the current row, without collapsing them into one row as GROUP BY does. Common examples are ROW_NUMBER, RANK, running totals with SUM OVER, and LAG or LEAD to compare a row with the previous or next one.
Why it matters
Window functions answer questions like rank the top branches in each region, show month on month change or find each customer's most recent order, which are awkward otherwise. They appear often in data analyst and business analyst interviews and in real reporting work.
Example
To show month on month change in loan disbursals for each branch, the analyst uses LAG over months partitioned by branch. To find each customer's latest complaint, she uses ROW_NUMBER partitioned by customer and ordered by date, keeping row number one.