SQL Quiz
Test your SQL query writing skills. — 8 questions
About the SQL Quiz
Test your SQL query writing skills. This quiz has 8 multiple-choice questions. Each question has one correct answer, and you see an explanation straight after you answer, so you learn from every question — including the ones you get wrong. There is no time limit and nothing to sign up for; your answers are not stored.
The questions follow the material in the SQL Fundamentals guide and the SQL cheatsheet. Read them first if you want to prepare, or take the quiz cold to find the gaps in what you know.
Questions in this quiz
Preview the questions below. Each answer and its explanation are hidden until you choose to reveal them, so you can still take the quiz above without spoilers.
1. Which clause is used to filter rows?
Show answer
Answer: C. WHERE
WHERE filters individual rows before grouping. HAVING filters groups after GROUP BY.
2. What does COUNT(*) return?
Show answer
Answer: B. Number of rows
COUNT(*) counts all rows in the result set, including those with NULL values.
3. Which JOIN returns all rows from the left table?
Show answer
Answer: C. LEFT JOIN
LEFT JOIN returns all rows from the left table. If there's no match in the right table, NULLs are returned for right-side columns.
4. What does LIKE 'A%' match?
Show answer
Answer: C. Strings starting with A
The % wildcard matches zero or more characters. 'A%' matches any string beginning with A.
5. Which keyword removes duplicate rows from a result?
Show answer
Answer: B. DISTINCT
SELECT DISTINCT eliminates duplicate rows from the result set.
6. What is the correct order of SQL clauses?
Show answer
Answer: B. SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY
The standard query order is: SELECT … FROM … WHERE … GROUP BY … HAVING … ORDER BY …
7. Which operator checks if a value is missing?
Show answer
Answer: C. IS NULL
You cannot compare NULL with =. Use IS NULL or IS NOT NULL instead.
8. What does HAVING do?
Show answer
Answer: B. Filters groups after GROUP BY
HAVING is like WHERE but applied after GROUP BY. It filters aggregated groups.
How to use this quiz
- Answer every question before reading the explanations below — retrieving an answer from memory is what makes it stick.
- Note the questions you missed and revisit the matching section of the guide or cheatsheet.
- Retake the quiz a day or two later. Spaced repetition is one of the most reliable ways to remember technical details.