2 Quizzes•14 Questions

Learn SQL

From SELECT and filtering to joins, grouping and NULL semantics, these quizzes emphasise reading queries and predicting their results.

What you will practise

  • Filtering and sorting
  • Joins and their edge cases
  • GROUP BY and HAVING
  • NULL behaviour

SQL lesson

A short introduction to the ideas behind the quizzes, before you start practising.

SQL is the language used to ask relational databases for data. Most practical SQL problems come down to understanding the order operations actually happen in, and how NULL behaves differently from every other value.

Key concepts

SELECT, WHERE and ORDER BY

`SELECT` chooses columns, `WHERE` filters rows before any grouping happens, and `ORDER BY` sorts the final result. Without an `ORDER BY`, the order of returned rows is not guaranteed.

SELECT name, score
FROM students
WHERE score >= 60
ORDER BY score DESC;

JOINs combine tables

An `INNER JOIN` keeps only rows that match in both tables. A `LEFT JOIN` keeps every row from the left table, filling in NULLs where there is no match on the right, which is how you find “what’s missing”.

SELECT s.name, e.course_id
FROM students s
LEFT JOIN enrollments e ON e.student_id = s.id;

GROUP BY and HAVING

`GROUP BY` collapses rows into groups so you can aggregate them with functions like `COUNT` or `AVG`. `HAVING` filters those groups, which is why it can use aggregates while `WHERE` cannot.

SELECT course_id, COUNT(*) AS n
FROM enrollments
GROUP BY course_id
HAVING COUNT(*) > 10;

NULL is not a value

NULL means “unknown”. Comparing anything to NULL with `=` or `!=` gives NULL, not true or false, which is why you need `IS NULL` / `IS NOT NULL`, and why aggregates like `AVG` silently skip NULLs.

SELECT * FROM students WHERE middle_name IS NULL;

Common mistakes

  • Writing `WHERE column = NULL` instead of `WHERE column IS NULL`, which never matches.
  • Putting a filter on the right-hand table of a `LEFT JOIN` into `WHERE` instead of the `ON` clause, which silently turns it back into an inner join.
  • Using an aggregate function in `WHERE` instead of `HAVING`.
  • Forgetting that `SELECT DISTINCT` and `GROUP BY` can hide duplicate or unexpected data rather than fixing the underlying query.

Quick recap

  • Filter rows with WHERE before grouping; filter groups with HAVING after grouping.
  • INNER JOIN keeps only matches; LEFT JOIN keeps every row from the left table.
  • NULL is unknown, not zero or empty; test it with IS NULL / IS NOT NULL.
  • Without ORDER BY, row order is not guaranteed by the database.

Ready to test this? Take the SQL Basics quiz →

Roadmap

Work through the levels in order, or jump to where you are.

1

Beginner

Querying

  • SELECT
  • WHERE
  • ORDER BY
  • LIMIT

SQL Basics

3

Intermediate

Combining data

  • INNER/LEFT JOIN
  • GROUP BY
  • HAVING
  • Subqueries

Joins & Aggregation

SQL quizzes

Interactive SQL challenges

Hands-on activities: find bugs, complete code, order steps and match concepts.

All SQL challenges →

SQL articles

FAQ

Which SQL dialect is used?

Standard SQL. Where MySQL and PostgreSQL differ, the explanation notes it.

Are these quizzes good for Data Analyst interviews?

Yes. Joins, GROUP BY, HAVING, and subqueries are the most frequently asked concepts in data analyst SQL rounds.

Do you cover database design or normalization?

Currently, the focus is on querying existing data (DML). Normalization and schema design (DDL) are planned for future Expert-level modules.

Is NoSQL covered here?

No. SQL covers relational databases. For NoSQL concepts, please check our MongoDB roadmap.