SQL Quiz
Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.
1. What kind of language is SQL?
You state what you want; the query planner decides how to get it (lesson 01).
2. Which clause chooses the rows a query returns?
SELECT chooses columns; WHERE filters rows (lesson 04).
3. What does WHERE category = 'Books' OR category = 'Toys' AND price < 20 return?
AND is evaluated before OR; use parentheses (lesson 05).
4. Without ORDER BY, in what order are rows returned?
Always use ORDER BY when order matters (lesson 06).
5. How many rows does LIMIT 5 OFFSET 10 return, and which?
OFFSET skips 10 rows, then LIMIT keeps 5 (lesson 07).
6. Is BETWEEN 30 AND 50 inclusive?
It means >= 30 AND <= 50 (lesson 09).
7. Which pattern matches names whose second letter is "a"?
_ matches exactly one character (lesson 10).
8. How do you find rows where city is missing?
Comparisons with NULL are unknown; use IS NULL (lesson 11).
9. What does NOT IN (1, 2, NULL) return?
The NULL makes every comparison unknown — prefer NOT EXISTS (lesson 09).
10. In SQLite and PostgreSQL, what is 7 / 2?
Integer divided by integer gives an integer; write 7 / 2.0 (lesson 13).
11. Why can 0.1 + 0.2 show 0.30000000000000004?
Use exact DECIMAL types or integer cents for money (lesson 15).
12. What is the difference between COUNT(*) and COUNT(email)?
COUNT(*) counts rows (lesson 18).
13. Which clause filters groups after aggregation?
WHERE runs before grouping (lesson 20).
14. In the logical order of a query, which runs first?
FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT (lesson 20).
15. A many-to-many relationship (orders and products) is stored using…
order_items links orders and products (lesson 22).
16. What does an INNER JOIN do with rows that have no match?
Outer joins keep unmatched rows (lessons 23–24).
17. How do you find customers with no orders using a join?
Keep every customer, then keep those with no match (lesson 24).
18. In a LEFT JOIN, putting a condition on the right table in WHERE instead of ON…
Conditions on the right-hand table usually belong in ON (lesson 24).
19. How many rows does a CROSS JOIN of 10 rows and 15 rows produce?
Every combination: 10 × 15 (lesson 25).
20. What's the difference between UNION and UNION ALL?
UNION ALL is faster when duplicates don't matter (lesson 28).
21. What makes a subquery correlated?
It's evaluated for each outer row (lesson 30).
22. What is a CTE?
Common Table Expressions make complex queries readable (lesson 31).
23. How do window functions differ from GROUP BY aggregates?
Each row keeps its identity and gains a value from its window (lesson 33).
24. Salaries 90, 80, 80, 70 ranked descending with DENSE_RANK() give…
RANK() would give 1, 2, 2, 4 (lesson 34).
25. What happens with UPDATE products SET stock = 0;?
Always check your WHERE clause (lesson 36).
26. What does ROLLBACK do?
Transactions are all-or-nothing (lesson 39).
27. What does a foreign key constraint prevent?
It protects referential integrity (lesson 43).
28. A table stores customer email on every order row. What problem does this cause?
Normalisation stores each fact once (lesson 45).
29. Why might WHERE lower(email) = '…' be slow on a large table?
Keep conditions sargable, or index the expression (lessons 46 and 51).
30. What is the reliable defence against SQL injection?
Parameters keep data separate from SQL code (lesson 50).
Want more practice? Try the exercises, or revisit any lesson from the course home.