Home › Interview & Career › SQL Practice

SQL Practice — Interview Questions with a Live Database

Practice SQL online with a real database in your browser. 27 graded SQL interview questions from easy to hard: joins, GROUP BY, HAVING, subqueries, CTEs, window functions and second-highest salary. Instant answer checking, hints and solutions.

Loading database…

Progress

0 of 0 solved

Schema

Tip: SELECT * FROM employees; to explore. Free play: choose “Playground”.

How SQL Practice works

A real SQLite database runs entirely in your browser (via WebAssembly). Pick a challenge, write a query and press Check answer: your result is compared row by row with the reference solution. Column names don't matter, only the values — and row order only matters when the question asks for a specific order.

What the challenges cover

  • Easy: SELECT, WHERE, ORDER BY, LIMIT, DISTINCT, COUNT and SUM
  • Medium: INNER and LEFT JOINs, anti-joins, GROUP BY with HAVING, self joins, dates and subqueries
  • Hard: second and Nth highest salary, top-N per group, DENSE_RANK, running totals, LAG, CTEs and conditional aggregation

Tips for SQL interviews

  • Say your plan out loud before typing: which tables, which join, what grain the result should have.
  • Watch for NULLs — LEFT JOIN + IS NULL finds missing rows, and NOT IN behaves unexpectedly when the subquery returns NULL.
  • Know the difference between RANK, DENSE_RANK and ROW_NUMBER — ties are a favourite follow-up question.
  • WHERE filters rows before grouping; HAVING filters groups after.

Your progress and queries are saved in this browser only. Nothing is uploaded.

More Interview & Career