SQL Practice

1,500 free SQL practice problems with solutions, graded against a real Postgres warehouse with randomized seed data. Sourced from verified data engineering interview reports. 10 topic catalogs, 4 difficulty bands.

1,500 SQL practice problems with worked solutions, graded against a real Postgres 16 instance. Randomized seed data on every submission catches the lucky-fixture solutions most online SQL trainers let through. Pulled from verified data engineering interview reports.

Prepare for the interview
01 / Open invite
02min.

Know the patterns before the interviewer asks them.

a SQL query, the same shape a screen would give you.
The diff against expected. Where ties broke. What you missed.
sandbox
1SELECT user_id,
2 COUNT(*) AS sessions
3FROM events
4WHERE ts >= NOW() - INTERVAL '7 day'
5
Execute your solution0.4s avg.
MicrosoftInterview question
Solve a problem

SQL practice topics, ranked by how often they show up in interviews

Each row opens that topic's filtered problem list. Counts update as new verified reports land in the catalog.

TopicProblemsDifficultyInterview weight
GROUP BY and aggregation142 problemsEasy → MediumHighest
Joins (INNER, LEFT, self, anti)168 problemsEasy → HardHighest
Window functions124 problemsMedium → HardHigh
CTEs and recursive queries96 problemsMedium → HardHigh
Subqueries and EXISTS88 problemsMedium → HardMedium
Date and time78 problemsMediumMedium
CASE WHEN and conditional logic64 problemsEasy → MediumMedium
Strings and regex64 problemsEasy → MediumMedium
NULL handling (COALESCE, NULLIF)52 problemsEasy → MediumMedium
Gaps and islands38 problemsHardSenior signal

What the grader actually does

Every submission spins up a fresh Postgres database with randomized seed data inside the problem's schema. The grader runs your query against ten of those seeds. A query that hard-codes a value, depends on insertion order, or uses LIMIT without an ORDER BY tiebreaker passes one seed and fails the rest. The grader tells you which seed broke and what changed.

Prepare for the interview
03 / From the bank03 of many
03hand-picked.

Top Active Senders per Channel

Medium26 min

Top three messages per channel by replies.

Pulled from debriefs where SQL was the gate.

10
Random seeds per submit
Your query has to pass every one to be accepted.
<800ms
Cold-start latency
Hot reruns under 200ms. The grader is not the bottleneck.
85%
Dialect-portable
Runs the same in Snowflake, BigQuery, Redshift, MySQL.

A four-week study plan that actually works

Built from what working candidates do, not from a course catalog. Week 3 is the one most people underweight and regret later.

WeekFocusProblemsTime-box per problem
Week 1SELECT, WHERE, GROUP BY with HAVING, INNER and LEFT JOIN20 Easy5 to 8 minutes
Week 2Multi-table joins, conditional aggregation with CASE inside SUM, date functions, the many-to-many duplication trap20 Medium10 to 15 minutes
Week 3Window functions in full: ROW_NUMBER, RANK and DENSE_RANK, LAG, LEAD, running totals, the dedup pattern. Plus CTEs and three recursive ones15 Medium to Hard12 to 20 minutes
Week 4Timed drills. Speak the solution out loud while writing it. Add gaps-and-islands and three pivots.10 mixed + 3 mocks15 Medium, 25 Hard

5 bugs the grader catches that other tools don't

These failure modes show up in real interview rounds. The grader on this site catches them because every submission runs against ten randomized fixtures, not one reference dataset.

Hard-coded value
Your query references a specific customer_id or order_id from the sample data. Passes one seed, fails the other nine.
LIMIT without ORDER BY
Postgres does not guarantee row order without ORDER BY. LIMIT 1 picks a different row on each seed.
INNER JOIN that should be LEFT
Drops rows where the right side has no match. Works on the seed where every customer has an order. Fails the seed where some don't.
COUNT(col) vs COUNT(*)
Different answers when col can be NULL. Easy to write, hard to spot, and the interviewer's favorite trap.
Window without tiebreaker
ROW_NUMBER OVER (ORDER BY ts DESC) is non-deterministic when two rows share the same ts. Add an event_id DESC tiebreaker.

Common questions about SQL practice

Is SQL practice on DataDriven actually free?+
Yes. Every problem, every grader run, every worked solution. The catalog isn't monetized. Sign-in is optional and only saves your progress across devices.
What SQL dialect should I expect?+
Postgres 16. About 85 percent of problems are dialect-portable to Snowflake, BigQuery, Redshift, and MySQL. Postgres-specific syntax (FILTER, RANGE BETWEEN, lateral joins, DISTINCT ON) is tagged. The dialect filter at the top of /problems narrows to portable SQL only.
Can I practice SQL online without installing anything?+
Yes. No local setup, no IDE, no Docker, no database to seed. The grader runs in your browser tab against a managed Postgres instance and returns results in under a second.
How many SQL problems do I need before a real interview?+
Most candidates who pass a data engineering loop have done 80 to 150 problems. Quality matters more than count. A problem you wrote, ran, debugged, explained out loud, and could re-derive a week later is worth 10 you skimmed. The signal you're ready is being able to write a Medium window-function problem in under 12 minutes without looking up syntax.
How is this different from LeetCode SQL or HackerRank?+
LeetCode and HackerRank target software engineers; their SQL questions are a side feature with one fixture per problem. The bank here is built from data engineering interview debriefs and the grader runs against ten randomized fixtures per submission. It catches the lucky-fixture solutions other tools let through.
Where can I find SQL problems by company?+
Every problem traces to verified interview reports. When a report explicitly cited a company, the problem is tagged. The company filter at /problems narrows the bank to problems reported in loops at Stripe, Meta, Databricks, and the long tail.
02 / Why practice

Start with the topic you've been avoiding

  1. 01

    Active recall beats re-reading by 50%

    Cognitive-science meta-reviews (Dunlosky et al., 2013) rank practice testing as a top-tier study technique, while re-reading and highlighting rank near the bottom

  2. 02

    76% of hiring managers reject on the coding task, not the resume

    From HackerRank's 2024 Developer Skills Report. Candidates who look strong on paper still fail the live screen if they haven't done timed, executable practice

  3. 03

    Five problem shapes cover 80% of data engineer loops

    Dedup, sessionization, top-N-per-group, slowly-changing dimensions, partition tricks. Writing the shapes by hand turns the unfamiliar into pattern recognition

More SQL resources