SELECT country FROM customers returns 12 rows: CA three times, US twice. To list each country once, add DISTINCT.
sql
SELECT DISTINCT country
FROM customers;SELECT country
| country |
|---|
| CA |
| CA |
| IT |
| US |
| US |
| CA |
DISTINCT goes right after SELECT. It removes duplicate rows: rows that are equal in every column of the result.
Several columns
With more than one column, DISTINCT keeps each different combination:
sql
SELECT DISTINCT country, is_member
FROM customers;SELECT country, is_member
| country | is_member |
|---|---|
| CA | true |
| CA | false |
| CA | true |
| US | false |
| US | true |
DISTINCT works on the result, so it uses only the columns in the SELECT list. You can sort the result with ORDER BY too.