How to use the SQL Practice Questions
- 1. Pick a questionChoose a question and open the table list to see the columns.
- 2. Write your SQLType a query and press Run only to test it, or Check answer.
- 3. Compare resultsThe checker compares your rows with a model answer and tells you what differs.
The practice database
Three small tables are loaded fresh each time you run a query: departments (4 rows), employees (10 rows with salary, hire date, city and manager) and orders (8 sales). Because the data is small, you can check results by eye while you learn.
Questions build from simple SELECT and WHERE to GROUP BY with HAVING, INNER and LEFT JOIN, self joins and subqueries. One example: the second highest salary. The model query is SELECT MAX(salary) FROM employees WHERE salary < (SELECT MAX(salary) FROM employees); and the answer in this data is 88000, because the top salary is 95000.
How answer checking works
The checker runs your query and a model answer on the same data, then compares the result rows. Column names and aliases do not matter, so COUNT(*) AS total and COUNT(*) both pass. Row order is ignored unless the question says order matters. Decimal results are compared to six places, so AVG works however you round it.
The SQL engine is SQLite compiled to WebAssembly (the open-source sql.js library, version 1.10.3, loaded from cdnjs). It runs entirely in your browser; your queries are never sent to a server. SQLite syntax is close to MySQL and PostgreSQL for these questions, but a few functions differ, such as using || to join text.
Ready for more? Try the window functions playground or build queries with the SQL query builder.
Frequently asked questions
Can I break the database?
No. Every run starts from a fresh copy of the sample data, so DELETE or DROP statements only affect that one run.
Why does my correct query fail?
Check that you return the same columns as the question asks, and that you included or excluded NULL rows as described. The message tells you if the row or column count differs.
Is the SQL Practice Questions free?
Yes, the SQL Practice Questions is free. The first time you run or check your first query, you are asked for your name and WhatsApp number once. After that, this and every other Uncodemy tool opens straight away without the form.