🏋️ 200+ exercises · skill-tracked · free

SQL Exercises — 200+ problems, full solutions

Browse by topic, difficulty, company, or industry. Every exercise has sample data, expected output, AI-explained hints, and a worked solution. The skill radar tracks where you're strong and where you need more reps.

Open the Exercise Bank → See the categories ↓

Or let the Coach pick — 1 click, the next exercise targets your weakest skill.

200+
Exercises
10
Skill categories
13
Company tags
3
Industry tracks
Browse

Four ways to slice the exercise bank

Pick the lens that matches what you're trying to do — close a topic gap, prep for a specific company, or just drill at a difficulty.

What an exercise looks like

A sample walked through

Every exercise on SQL Quest has the same anatomy: prompt, sample data, expected output, your editor, instant feedback. Here's a Medium-difficulty Window Function exercise.

Medium Window Functions PARTITION BY

Top 3 Highest-Paid Employees per Department

📋 The prompt

For each department, find the top 3 highest-paid employees. If two employees are tied at the same salary, both should appear (and they share the rank). Output columns: name, department, salary, ordered by department, then salary descending.

📊 Sample data — employees

idnamedepartmentsalary
1AliceEngineering180000
2BobEngineering170000
3CarolEngineering170000
4DanSales120000
5EveSales110000

✅ Expected output

namedepartmentsalary
AliceEngineering180000
BobEngineering170000
CarolEngineering170000
DanSales120000
EveSales110000

💡 Hint progression

Hint 1: "Ranking ties — which window function keeps both Bob and Carol at rank 2 instead of giving one rank 3?"
Hint 2: "Wrap your ranked query in a CTE. You can't filter on a window function in the same WHERE."
Show Structure: skeleton with WITH/PARTITION/ORDER BY blanks.

🔓 Solution (revealed only when you ask)

WITH ranked AS ( SELECT name, department, salary, DENSE_RANK() OVER ( PARTITION BY department ORDER BY salary DESC ) AS rk FROM employees ) SELECT name, department, salary FROM ranked WHERE rk <= 3 ORDER BY department, salary DESC;
See 33 Window Function Exercises →
Skill tracking

Every exercise feeds the skill radar

SQL Quest tracks your proficiency across 10 canonical skills. Each exercise contributes points to the skills it exercises — weighted by difficulty, your speed, and how many hints you used.

More points

Cold solve, no hints

First-attempt solve on a Hard exercise without revealing structure or asking the AI Coach. The clearest signal of real mastery.

Some points

Solve with hints

Used Show Structure or asked the Coach. Still counts — you learned something — but at a discount. The radar reflects guided solves differently than cold ones.

Mastery check

Fresh-solve on unseen exercise

After a lesson, the Coach drops you on 2-3 unseen exercises in the same skill. Recognition isn't enough; you have to produce. That's what gates advancement.

Frequently Asked

200+ exercises waiting.
Open the bank.

Free, browser-only, no signup. The Coach can pick the next exercise — or you can browse.

Open SQL Quest — Free ⚡