DISTINCT gives one of each value
Ask for the city column and you get one row per student, so the same city shows up again and again. DISTINCT folds those repeats together, leaving one row for each different value. It's how you turn a long column into a list of the values that exist.
A tiny example
In plain English: Show me the list of cities students come from, each city once.
SELECT DISTINCT city
FROM students;What comes back
| city |
|---|
| Lisbon |
| Oslo |
| Porto |
Many students share a city, but each city appears only once here.
Related SQL lessons
Ready for a break?
Take on today's cozy puzzle. A fresh, bite-sized query waits every morning — no timers, no pressure.
play today's sip