What is a window function, and when would you use one?
What they're checking
Whether you know window functions beyond the name, since they solve many analyst problems neatly.
A strong answer covers
- Define it as a calculation across related rows that keeps every row, unlike GROUP BY, which collapses them.
- Describe the syntax, a function followed by OVER with PARTITION BY and ORDER BY.
- Give two or three uses, such as running totals, ranking with ROW_NUMBER or RANK, and comparing a row with the previous one using LAG.
- Mention a query you wrote with one and what it replaced, such as a self-join.