Skip to interview prep
Apexed

3. What are window functions? Give an example.

MediumSQL

Technical

Type or dictate your answer. Your draft is saved on this device.

Show model answer

Window functions compute values across related rows without collapsing them like GROUP BY does. Examples: ROW_NUMBER, RANK, running totals with SUM() OVER, and LAG/LEAD for previous or next values.

Running revenue by day: `SELECT day, revenue, SUM(revenue) OVER (ORDER BY day) AS running_total FROM daily_sales;`

What are window functions? Give an example. — Data & analytics interview question — Apexed