SQL – Window Functions
Practice SQL window functions commonly asked in data analyst and data engineer interviews. Cover ROW_NUMBER, RANK, DENSE_RANK, running totals, and partitioning. Write queries and receive feedback on correctness and approach. Ideal for intermediate SQL interview prep. First 2 questions are free with full feedback.
- Level Intermediate
- Questions 12
Try any track free — first 2 questions include full AI feedback. Subscribe to finish the track and unlock everything. Type or speak your answer — the first 2 questions include scoring and detailed AI feedback.
Sample sql – window functions interview questions
Preview 6 questions from this track in quiz order. In the full quiz you answer one at a time — type or speak — then get a score and feedback.
-
What is the difference between ROW_NUMBER, RANK, and DENSE_RANK?
What a strong answer includes
Explains how each handles ties.
-
Write a query to get the top 3 highest-paid employees in each department.
What a strong answer includes
Uses ROW_NUMBER or RANK with PARTITION BY department.
-
How do you calculate a running total of sales by date?
What a strong answer includes
Uses SUM() OVER (ORDER BY date).
-
Write a query to find the second-highest salary in each department.
What a strong answer includes
Uses a window function or subquery correctly.
-
Explain PARTITION BY in a window function.
What a strong answer includes
Describes how it groups rows for the calculation without collapsing them.
-
Write a query to rank products by sales within each category.
What a strong answer includes
RANK or ROW_NUMBER with PARTITION BY category.