Learn Quiz

SQL Quiz

Test your SQL query writing skills. — 8 questions

Question 1 of 8 Score: 0

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?

  1. SELECT
  2. GROUP BY
  3. WHERE
  4. HAVING
Show answer

Answer: C. WHERE
WHERE filters individual rows before grouping. HAVING filters groups after GROUP BY.

2. What does COUNT(*) return?

  1. Sum of all values in a column
  2. Number of rows
  3. Number of columns
  4. Average value
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?

  1. INNER JOIN
  2. RIGHT JOIN
  3. LEFT JOIN
  4. CROSS JOIN
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?

  1. Strings ending with A
  2. Strings containing A
  3. Strings starting with A
  4. Exactly the string 'A%'
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?

  1. UNIQUE
  2. DISTINCT
  3. FILTER
  4. EXCLUDE
Show answer

Answer: B. DISTINCT
SELECT DISTINCT eliminates duplicate rows from the result set.

6. What is the correct order of SQL clauses?

  1. FROM → SELECT → WHERE → GROUP BY → HAVING → ORDER BY
  2. SELECT → FROM → WHERE → GROUP BY → HAVING → ORDER BY
  3. WHERE → FROM → SELECT → HAVING → GROUP BY → ORDER BY
  4. SELECT → WHERE → FROM → GROUP BY → ORDER BY → HAVING
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?

  1. = NULL
  2. == NULL
  3. IS NULL
  4. NULL = NULL
Show answer

Answer: C. IS NULL
You cannot compare NULL with =. Use IS NULL or IS NOT NULL instead.

8. What does HAVING do?

  1. Filters rows before grouping
  2. Filters groups after GROUP BY
  3. Sorts the result
  4. Joins two tables
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.

Related