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?

2. Which clause chooses the rows a query returns?

3. What does WHERE category = 'Books' OR category = 'Toys' AND price < 20 return?

4. Without ORDER BY, in what order are rows returned?

5. How many rows does LIMIT 5 OFFSET 10 return, and which?

6. Is BETWEEN 30 AND 50 inclusive?

7. Which pattern matches names whose second letter is "a"?

8. How do you find rows where city is missing?

9. What does NOT IN (1, 2, NULL) return?

10. In SQLite and PostgreSQL, what is 7 / 2?

11. Why can 0.1 + 0.2 show 0.30000000000000004?

12. What is the difference between COUNT(*) and COUNT(email)?

13. Which clause filters groups after aggregation?

14. In the logical order of a query, which runs first?

15. A many-to-many relationship (orders and products) is stored using…

16. What does an INNER JOIN do with rows that have no match?

17. How do you find customers with no orders using a join?

18. In a LEFT JOIN, putting a condition on the right table in WHERE instead of ON…

19. How many rows does a CROSS JOIN of 10 rows and 15 rows produce?

20. What's the difference between UNION and UNION ALL?

21. What makes a subquery correlated?

22. What is a CTE?

23. How do window functions differ from GROUP BY aggregates?

24. Salaries 90, 80, 80, 70 ranked descending with DENSE_RANK() give…

25. What happens with UPDATE products SET stock = 0;?

26. What does ROLLBACK do?

27. What does a foreign key constraint prevent?

28. A table stores customer email on every order row. What problem does this cause?

29. Why might WHERE lower(email) = '…' be slow on a large table?

30. What is the reliable defence against SQL injection?

Want more practice? Try the exercises, or revisit any lesson from the course home.