SQL Practice Problems
The best way to learn SQL is by writing SQL. QueryU offers 70 graded challenges across three difficulty tiers — start free, no setup required.
Reading about SQL is not the same as writing it. Concepts like JOIN, GROUP BY, and window functions are easy to follow on the page and surprisingly hard to apply on a deadline. The gap closes only one way: by writing query after query, getting it wrong, reading the error, and trying again. That feedback loop is what turns SQL from a topic you have studied into a tool you can actually use.
QueryU runs every challenge against a real PostgreSQL database loaded with a university records dataset — admissions, enrollment, course sections, grades, advising and financial aid, across 18 tables. Your query is executed against the same data the answer key uses, then the result sets are compared row-by-row. If your output matches, you pass. There is no fragile "is your SQL identical to mine" check; multiple correct approaches all earn credit.
Difficulty climbs deliberately. Easy problems isolate one concept at a time so you can build muscle memory. Medium problems combine three or four concepts the way a real ad-hoc analytics question would. Hard problems pull in window functions, recursive CTEs, and performance-aware patterns — the queries you would actually write as a data analyst at a university registrar or institutional research office.
Challenges by difficulty
Perfect for beginners. These challenges cover the fundamentals every SQL learner needs. You will write simple queries that filter, sort, and aggregate data from a single table.
Concepts covered:
Ready to combine tables? Medium challenges introduce JOINs, subqueries, and multi-step logic. You will work with related tables like ods_students, ods_student_terms, and ods_course_sections.
Concepts covered:
For experienced SQL developers. Hard challenges require advanced techniques like window functions, recursive CTEs, and multi-layered aggregations.
Concepts covered:
Start with these five
One rung at a time, from your first SELECT to a recursive CTE. The first three are in the free tier.
Department Directory
EasyThe first challenge — a single SELECT with an ORDER BY. Fifteen seconds to your first pass.
Student Headcount by Class
EasyYour first GROUP BY with COUNT, on one table.
Admissions Funnel
MediumTwo-column GROUP BY producing a real funnel report by term and status.
Enrollment Counts by Course
Requires ProMediumA three-table join feeding an aggregate — the shape of most analyst work.
Cohort Retention Funnel via Recursive CTE
Requires ProHardThe hardest thing in the bank: a recursive CTE walking terms forward through a cohort.
How QueryU is different
The four things SQL learners complain about most across the category — and what we do instead.
| What learners ask for | Most SQL practice sites | QueryU |
|---|---|---|
| A grader that doesn't fail correct queries on whitespace or sort order | Strict text comparison — extra spaces, blank lines, and tied sort orders silently fail | Result-set grading. Any valid SQL that returns the right rows passes. |
| Realistic data, not the same employees-and-departments schema | Toy schemas, fictional companies, < 5 tables, no NULLs, no time-series shape | Real university SIS dataset. 18 tables, real NULLs, real cohorts. |
| Write the query from scratch — not fill-in-the-blank | Scaffolded prompts with most of the query pre-written | Blank Monaco editor. You write every query yourself, in the same editor as VS Code. |
| Modern PostgreSQL, not 2010-era MySQL | MySQL or MariaDB by default — no FILTER, awkward DATE_TRUNC, no recursive CTEs in older builds | Real PostgreSQL. FILTER (WHERE), DATE_TRUNC, recursive CTEs, window functions — all native. |
Comparisons describe common patterns we hear about across the category — not any one site.
Why practice on QueryU?
Real Database
Query actual PostgreSQL tables with realistic university data — not toy examples.
Instant Grading
Your query runs immediately. See a row-by-row diff of your output vs. expected results.
Progress Tracking
Earn points, maintain streaks, unlock badges, and climb the leaderboard.
AI Hints
Stuck? Get diagnostic hints that point you in the right direction without spoiling the answer.
Frequently asked questions
How many SQL practice problems are there?
70 graded challenges — 21 Easy, 27 Medium, and 22 Hard. The first 31 by display order are free; the rest are included with Pro at $9 per month or $79 per year, or $5 per month / $44 per year on the student tier.
Do I need to install a database?
No. Every challenge runs against a hosted PostgreSQL database in the browser. There is no download, no Docker image, and no local setup — you write a query in the editor and it executes immediately.
How are the answers graded?
By result set, not by text. Your query runs against the same data as the answer key and the two outputs are compared row by row. Any valid SQL that returns the right rows passes, so a CTE, a subquery and a join that all reach the same answer all earn full credit.
What data do the challenges use?
A realistic university records dataset in the dbo schema — 18 tables covering admissions, enrollment, course sections, grades, advising and financial aid. It has real NULLs, real cohorts and real term structure, which is where most toy practice schemas fall down.
Which SQL dialect is used?
PostgreSQL. That means FILTER (WHERE), DATE_TRUNC, recursive CTEs and the full window-function set are all native, so the patterns you practice are the ones you will use at work.
Is QueryU good for SQL interview preparation?
Yes, particularly for data-analyst and analytics-engineer interviews. The Medium and Hard tiers cover the questions interviewers actually ask — multi-table joins, conditional aggregation, ranking window functions and cohort analysis — against a schema large enough that the answer is not obvious from the table list.
Start your first challenge now
No credit card, no setup, no sign-up to start. Pick a challenge and write SQL in under 30 seconds.
Related guides
SQL for Beginners
Learn SELECT, WHERE, ORDER BY
SQL JOINs Explained
INNER, LEFT, RIGHT & FULL joins
HAVING vs WHERE
The order-of-operations rule behind the Medium tier
SQL CTEs / WITH Clause
Single, chained and recursive — the Hard tier's backbone
SQL Practice Sites Compared
How five other platforms handle the same job