SQL · Pattern 1 — Basic Data Retrieval
DISTINCT
DISTINCT removes duplicate rows from the result — it looks at the full row (or the listed columns) and collapses repeats down to one.
Source data — Pattern 1: Basic Data Retrieval
All queries run against the shared employees table (see schema.sql).

What it does
DISTINCT removes duplicate rows from the result — it looks at the full row (or the listed columns) and collapses repeats down to one. It runs after the columns are selected, so SELECT DISTINCT department_id only cares about duplicate department_id values, not the whole row.
Problem
Find all unique departments.
SELECT DISTINCT department_id
FROM employees;

Tip
To show department names instead of IDs, this pairs naturally with a JOIN to departments — worth cross-linking once Pattern 6 is live.