All 60 SQL exercises
Querydrill is SQL practice in your browser. Every exercise gives you real tables, a question and an editor. You write the query, run it as often as you like, and it is checked on the rows it returns and again on a changed copy of the data, so guesses fail and working queries pass. The exercises are listed here level by level. 6 are free without an account; Pro unlocks the rest.
Level 1: Basics
SELECT, WHERE, ORDER BY, LIMIT, DISTINCT, IN, LIKE, NULL handling and CASE.
Level 2: Aggregation
COUNT, SUM, AVG, GROUP BY, HAVING, COUNT DISTINCT and grouping by dates.
Level 3: Joins
Inner, left and self joins, finding rows with no match, keeping zero counts.
- Orders with customer namesPro
- Customers who never orderedPro
- Revenue per countryPro
- Everyone with a departmentPro
- Employee and managerPro
- Revenue per productPro
- Revenue per categoryPro
- Products never soldPro
- Headcount per departmentPro
- Orders per customerPro
- Products per orderPro
- Customers from the same countryPro
Level 4: Advanced
Subqueries, CTEs, RANK, DENSE_RANK, ROW_NUMBER, LAG and running totals.
Level 5: Interview classics
Nth highest salary, earns more than the manager, pivots with CASE.
Level 6: Work mode
Requests from Marketing, Finance and Support on messy tables: text amounts, mixed date formats, duplicates and stray spaces.
Try the first six exercises free.
No sign-up needed for the first six, including one Work mode task. If it works for you, Pro unlocks all 60, and a free account saves your progress across devices.
Start practicing free