Quiz · 12 questions

SQL fundamentals quiz

12 questions on the traps interviewers love: NULLs, joins, window functions and query plans. Choose an answer for each, then check your score. Every "what does this return" answer was verified by running the query.

  1. Question 1 of 12Salaries are 100, 90, 90 and 80. What does DENSE_RANK() OVER (ORDER BY salary DESC) return for 80?
  2. Question 2 of 12Column x holds 1, NULL and 3. What does SELECT COUNT(x) FROM t return?
  3. Question 3 of 12Table A has 3 rows with key 1. Table B has 2 rows with key 1. How many rows does A INNER JOIN B ON A.key = B.key return?
  4. Question 4 of 12customers has ids 1, 2, 3. orders.customer_id holds 1 and NULL. How many rows does SELECT * FROM customers WHERE id NOT IN (SELECT customer_id FROM orders) return?
  5. Question 5 of 12Why can't you write WHERE ROW_NUMBER() OVER (...) = 1?
  6. Question 6 of 12order_date has an index. Which filter for the year 2026 can use it for a range seek?
  7. Question 7 of 12OVER (ORDER BY day) has no frame clause. Which frame does the window use?
  8. Question 8 of 12How many rows does SELECT COUNT(*) FROM t WHERE NULL = NULL count, if t has 5 rows?
  9. Question 9 of 12In PostgreSQL, SQL Server or SQLite, what does SELECT 1 / 2 return?
  10. Question 10 of 12How many rows does SELECT 1 UNION SELECT 1 UNION ALL SELECT 1 return?
  11. Question 11 of 123 customers; only customer 1 has an order, with status 'paid'. How many rows does customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.status = 'paid' return?
  12. Question 12 of 12Table t is empty. What does SELECT SUM(x) FROM t return?
0 of 12 answered

Revise the topics in the SQL Interview Questions guide, or work through the SQL question bank.