Excel to SQL · Lesson 10 of 12
Remove Duplicates is DISTINCT
SELECT DISTINCT gives each different value (or combination of values) once. It doesn't delete anything from the table; it just shows the unique list, like Excel's =UNIQUE().
Try itEdit the query, then Run
| country |
|---|
| Australia |
| Brazil |
| Canada |
| France |
| Germany |
| India |
| Nigeria |
| United Kingdom |
| United States |
9 rows
With several columns, DISTINCT removes rows where the whole combination repeats: SELECT DISTINCT region, product_id FROM orders lists every product each region has bought.
Your turn
List each different event_name in the events table, A to Z.
SELECT DISTINCT event_name FROM events, then ORDER BY.
This page on one card
