Free SQL interview practice. 12 lessons solve the classic problems with window functions, joins and CTEs, using one practice database and real query outputs.
Intermediate · 12 lessons
Start Here
How to Solve an SQL Interview Problem - A calm method for SQL interview problems, plus the practice database with employees, sales and logins used in every lesson of this course.
Ranking and Top Rows
Nth Highest Salary: Five Ways and the Traps - Solve the classic second and Nth highest salary problem with LIMIT, a subquery and DENSE_RANK, and learn how ties and a missing answer change the result.
Find and Delete Duplicate Rows in SQL - Find duplicates with GROUP BY and HAVING, label them with ROW_NUMBER, then delete the extra copies safely while keeping one row of each.
Top N per Group: Highest Paid in Each Department - Find the highest paid person in each department, or the top two, with ROW_NUMBER, RANK, DENSE_RANK and a correlated subquery, and handle ties.
Self Joins and Hierarchies: Employees and Managers - Join a table to itself to list employees with their manager, find people who earn more than their boss, count direct reports and walk the whole org chart.
Query Speed, Indexes and a Mock Interview Round - Read a query plan, see why a function on a column stops an index from helping, and finish with four timed practice problems and their answers.