Interview preparation
SQL Window Function Interview Questions
The window function questions that decide senior-level interviews: ranking, running totals, LAG/LEAD, and gaps and islands — with a practice progression.
Why window functions are the differentiator
Window functions separate junior from senior candidates. Interviewers use them for top-N-per-group, consecutive-day streaks, running totals, and previous-row comparisons — problems that are painful or impossible with plain GROUP BY.
The core skill is choosing the right function, then wrapping the query to filter on the window result.
Practice questions
- easyRising Temperature
- mediumConsecutive Login Days
- mediumConsecutive Numbers
- mediumFirst and Last Order Per Customer
- mediumGame Play Analysis IV
- mediumImmediate Food Delivery
- mediumLatest Event Per User
- mediumLongest Login Streak
- mediumMonthly Sales Ranking
- mediumNth Highest Salary
- mediumOrders Gap Analysis
- mediumPercentage of Total Sales
- mediumRank Scores
- mediumRunning Total
- mediumSeven-Day Rolling Average
- hardTop Three Per Category