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.

First 31 challenges free

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

Easy21 challenges
10 pts each

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:

SELECT & FROMWHERE filtersORDER BY & LIMITBETWEEN & UNIONINITCAP & COALESCE
Medium27 challenges
25 pts each

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:

INNER & LEFT JOINAnti-join patternGROUP BY with HAVINGFILTER aggregationDATE_TRUNC & EXCEPT
Hard22 challenges
50 pts each

For experienced SQL developers. Hard challenges require advanced techniques like window functions, recursive CTEs, and multi-layered aggregations.

Concepts covered:

Window functionsRecursive CTEsEXCEPT & set operationsLEFT JOIN + COALESCENULLIF & advanced filtering

How QueryU is different

The four things SQL learners complain about most across the category — and what we do instead.

What learners ask forMost SQL practice sitesQueryU
A grader that doesn't fail correct queries on whitespace or sort orderStrict text comparison — extra spaces, blank lines, and tied sort orders silently failResult-set grading. Any valid SQL that returns the right rows passes.
Realistic data, not the same employees-and-departments schemaToy schemas, fictional companies, < 5 tables, no NULLs, no time-series shapeReal university SIS dataset. 18 tables, real NULLs, real cohorts.
Write the query from scratch — not fill-in-the-blankScaffolded prompts with most of the query pre-writtenBlank Monaco editor. You write every query yourself, in the same editor as VS Code.
Modern PostgreSQL, not 2010-era MySQLMySQL or MariaDB by default — no FILTER, awkward DATE_TRUNC, no recursive CTEs in older buildsReal 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.