Skip to content
ohsudo, Home

SQL Exercises

Practice queries on real PostgreSQL and SQLite in your browser, with instant checking of your results.

● Runs 100% in your browser — nothing you type leaves this page.

How it works

Pick a topic, and write a query for each task. The result is compared with the right answer, so any query that gets it right passes, however you wrote it.

What the checks look at

They compare the rows and columns you got with those of the solution. Column names and their order don’t count. The order of rows only counts when a task asks for it, as a query with no ORDER BY has no guaranteed order.

If the result is wrong, you’re told how: too many rows, too few columns, or the right shape with different values. You see your own result too, so you can work out why.

FAQ

Which tab should I use?

Use the database you work with, or PostgreSQL if you’re not sure. Most of what’s here works the same on both, and differences are pointed out where they matter. To compare with MySQL, SQL Server or Oracle, see the SQL Dialect Reference.

Where can I just try things?

In the SQL Playground, with the same sample data and a full editor.

My query works in MySQL. Why does it fail here?

Databases differ more than you’d expect, in quoting, dates and text functions. If you’re getting an error on your own server, see MySQL error 1064 or column must appear in the GROUP BY clause.

Is my SQL sent anywhere?

No. It runs on the database in your browser, and never leaves it.

Articles

Learn more