Skip to content

Practise SQL

SQL challenges

25 SQL exercises on real-looking data, from a first WHERE to window functions. Write the query, press Run & check, and see straight away if it's right. Free, in your browser, no sign-up.

0 of 25 solved
Start the first challenge

Your progress is saved in this browser only.

Easy 8 challenges

  1. 1 Customers from Sri Lanka SELECT · WHERE · ORDER BY
  2. 2 Out-of-stock products SELECT · WHERE
  3. 3 The most expensive product ORDER BY · LIMIT · subquery
  4. 4 Count orders by status GROUP BY · COUNT
  5. 12 Restock empty shelves UPDATE · WHERE
  6. 14 Salaries in Engineering JOIN · WHERE · ORDER BY
  7. 15 Employees without a department IS NULL
  8. 16 The second-highest salary subquery · MAX

Medium 13 challenges

  1. 5 Customers who never ordered LEFT JOIN · IS NULL · NOT EXISTS
  2. 6 Customers who ordered more than once JOIN · GROUP BY · HAVING
  3. 7 Total of each order GROUP BY · SUM · expressions
  4. 8 Each customer's first order JOIN · GROUP BY · MIN
  5. 9 Orders per month GROUP BY · date functions
  6. 10 Revenue per category JOIN · GROUP BY · SUM
  7. 11 The best customer JOIN · GROUP BY · ORDER BY · LIMIT
  8. 18 Headcount per department LEFT JOIN · GROUP BY · COUNT
  9. 19 Employees and their managers self join · LEFT JOIN
  10. 20 Earns more than their manager self join
  11. 21 Team size of each manager self join · GROUP BY
  12. 22 Hires per year GROUP BY · date functions
  13. 25 Give Support a pay rise UPDATE · subquery

Hard 4 challenges

  1. 13 Running revenue of delivered orders window functions · SUM OVER · CTE
  2. 17 The fourth-highest distinct salary DENSE_RANK · DISTINCT · LIMIT OFFSET
  3. 23 Above their department average correlated subquery · AVG · window functions
  4. 24 Top earner in each department window functions · RANK · subquery
SQL Playground: Run SQL Queries Online Write any query on the same sample tables, or create your own. SQL interview questions Joins, GROUP BY, window functions and indexes, with answers.

Get new articles in your inbox

Practical tutorials and deep dives, about once a week. No spam, unsubscribe anytime.

Privacy policy

Add DEV Talk to your Home Screen

  1. 1 Tap the Share button in Safari's toolbar.
  2. 2 Scroll down and tap Add to Home Screen.
  3. 3 Tap Add. Open it from the Home Screen to read like an app and to turn on notifications with the bell.

We use cookies to improve your experience and analyze traffic. By continuing, you agree to our Privacy Policy.