HomeInterview QuestionsWindow Functions Interview Questions

Window Functions Interview Questions

27 real Window Functions questions asked in live technical interviews — each with a model answer. Updated weekly.

🎤 Auto-captured by Assisting AI during live interviews

These Window Functions interview questions were captured from real interviews by candidates using Assisting AI. Each links to a full model answer. For real-time help during your own interview, get Assisting AI from ₹500/day.

Write a simple SQL query to find customers who placed orders on three consecutive days.🟡 Medium · Coding · Asked 2×How would you use a Spark window function with row_number() partitioned by customer and ordered by timestamp descending to get the latest order per customer?🟡 Medium · Coding · Asked 1×What is the output of the ROW_NUMBER() function in SQL?🟢 Easy · Conceptual · Asked 1×How do you calculate a running total, such as a running salary, where the first entry is 1000 rupees and the second is 3000 rupees, accumulating over time?🟡 Medium · Coding · Asked 1×For each employee, generate a new column that contains the running total of salaries.🟡 Medium · Coding · Asked 1×Write an SQL query that, given a table with columns id, year, and revenue, returns for each row the previous year's revenue and the revenue difference.🟡 Medium · Coding · Asked 1×Using a window function, how would you find duplicate rows in a table using SQL?🟡 Medium · Coding · Asked 1×Write an SQL query that returns the top two highest‑paid employees from each department.🟡 Medium · Coding · Asked 1×Write an SQL query that joins the Employee and Department tables to display employee name, department name, and salary, and then uses a window function to rank employees by salary within each department.🟡 Medium · Coding · Asked 1×Find the top three products in each category.🟡 Medium · Coding · Asked 1×Row numbers are used, but they don't check for consecutive purchases. The number only indicates whether there are more than three purchases. How can we modify this to check for consecutive purchases?🟡 Medium · Coding · Asked 1×Customer ID 1 meets the criteria because they made purchases on 25th Jan, 26th Jan, and 27th Jan – three consecutive days. Customer ID 2 does not meet the criteria because, although they made more than three purchases, the dates are not consecutive. Write an SQL query to find customer IDs of customers who have made purchases on at least three consecutive days.🟡 Medium · Coding · Asked 1×What is the difference between LAG and LEAD functions?🟢 Easy · Conceptual · Asked 1×Are you familiar with window functions? Can you explain any window function you have used in real time?🟡 Medium · Conceptual · Asked 1×Can you get a single dense rank?🟢 Easy · Conceptual · Asked 1×Can you explain rank, dense rank, and row number?🟡 Medium · Conceptual · Asked 1×Can you tell the difference between rank, dense rank, and row number?🟡 Medium · Conceptual · Asked 1×Can you explain the difference between the DENSE_RANK and ROW_NUMBER window functions?🟡 Medium · Conceptual · Asked 1×Are you familiar with SQL window functions?🟢 Easy · Conceptual · Asked 1×Find the top 3 highest salaries in each department.🟡 Medium · Coding · Asked 1×How would you find the second highest paid employee in each department?🟡 Medium · Coding · Asked 1×Briefly explain row number, rank, and dense rank.🟡 Medium · Conceptual · Asked 1×Provide code for dense rank and row number.🟡 Medium · Coding · Asked 1×Explain the differences between ROW_NUMBER, RANK, and DENSE_RANK window functions.🟡 Medium · Conceptual · Asked 1×What is the difference between window functions and aggregate functions?🟡 Medium · Conceptual · Asked 1×You need the latest record per (id) from a change‑log table with multiple updates per day and occasional ties on timestamp. Which SQL pattern is most reliable?🟡 Medium · Conceptual · Asked 1×How can you compute a cumulative sum (running balance) ordered by date using an unbounded preceding window specification in a Spark DataFrame?🟡 Medium · Conceptual · Asked 1×

🎤 Get Window Functions questions answered in real-time

Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.

Get Assisting AI — Starts at ₹500

Browse Other Topics