Home/Practice SQL for interviews
// Guide
How to practice SQL for interviews
The best way to practice SQL for interviews is to write real queries against real data and check them by running them - not to read or watch. Focus on the handful of patterns interviews actually test - JOINs, GROUP BY and HAVING, subqueries, CTEs, and window functions - drill each until you can write it without hints, and keep a list of the mistakes you repeat so you can retest them.
// A method that works
Five steps to interview-ready SQL
Cover the core topics
Interviews reuse a small set of patterns. Get fluent in SELECT/WHERE, GROUP BY, HAVING, the JOIN types, subqueries, CTEs, and window functions before anything exotic.
Write, do not watch
Reading solutions feels productive but does not build recall. Write every query yourself and run it - the muscle you need in the interview is writing, not recognizing.
Drill one pattern at a time
Take one pattern (say, HAVING) and do several problems until you can write it without hints. Then move on. Depth per pattern beats a scattershot problem count.
Track and retest your misses
Keep a list of the mistakes you actually make - filtering an aggregate with WHERE, NULLs dropping rows in a JOIN - and come back to them a few days later. Spaced retesting is what makes them stick.
Simulate the real thing
Time-box a few questions and say your approach out loud before you write. Interviewers care about how you reason, not just the final query.
-- customers with more than 2 orders
SELECT c.name
FROM customers c
JOIN orders o ON o.customer_id = c.id
GROUP BY c.id
HAVING COUNT(*) > 2; Try it - hit Run & grade.
// What to cover
The SQL topics interviews test
Interviews reuse a small set of patterns far more than they test obscure syntax. Get fluent in these and you have covered the large majority of what gets asked.
SELECT & WHERE
Filtering, comparisons, IN / BETWEEN / LIKE, and NULL handling.
Aggregation & GROUP BY
COUNT / SUM / AVG, grouping, and what you can and cannot select.
HAVING vs WHERE
Filtering rows before grouping vs filtering aggregates after.
JOINs
INNER, LEFT, self-joins, and how NULLs behave across them.
Subqueries & CTEs
Nested queries and readable WITH clauses for multi-step logic.
Window functions
ROW_NUMBER, RANK, running totals, PARTITION BY - the advanced favourite.
// Drill your misses
The mistakes worth drilling
Most lost points come from a few repeat mistakes, not exotic gaps. Watch for filtering an aggregate with WHERE instead of HAVING, rows disappearing because of NULLs in a JOIN, selecting columns that are not in your GROUP BY, and getting window-function ordering wrong. The fix is the same for all of them: when you miss, read why, then retest the same pattern a few days later.
// Questions
Practicing SQL for interviews - FAQ
What SQL topics do interviews test?
Most SQL interviews reuse a small set of patterns: SELECT and WHERE filtering, aggregation with GROUP BY, HAVING vs WHERE, the JOIN types (inner, left, self) and how NULLs behave, subqueries and CTEs, and window functions (ROW_NUMBER, RANK, running totals with PARTITION BY). Get fluent in those before anything exotic.
What is the best way to practice SQL for interviews?
Write real queries and check them by running them - not by reading or watching. Pick one pattern at a time, do several problems until you can write it without hints, then keep a list of the mistakes you repeat and retest them a few days later. Practicing by writing and running is what builds the recall you need under pressure.
How long does it take to prepare SQL for an interview?
For the fundamentals, a focused week or two of daily hands-on practice is usually enough to get comfortable; window functions and trickier JOIN and NULL cases take a bit longer. It depends more on writing queries every day than on total hours - consistency beats cramming.
Can I practice SQL for free?
Yes. Prepshotz is free during beta - you write real SQL in your browser and it is graded by running it against a real database, with hints and explanations built in. No install and no credit card.
Do I need to install a database to practice?
No. On Prepshotz the editor, the database, and the grading all run in your browser, so you can practice SQL without installing or configuring anything.