Excel to SQL · Lesson 10 of 12

Remove Duplicates is DISTINCT

In Excel, you'd reach for
fxData > Remove Duplicates, or =UNIQUE()

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.

This page on one card

Remove Duplicates is DISTINCT: the Excel way (Data > Remove Duplicates) and the SQL query, side by side
Remove Duplicates is DISTINCT, on one card: the Excel way and the SQL. Download · Save to Pinterest
The practice data (7 tables)

See every column and sample rows