DISTINCT values in SQL
DISTINCT collapses duplicate rows down to one each.
SELECT DISTINCT
country,
plan
FROM subscriptions
ORDER BY country;
How it works
- It applies to the whole selected row, not one column.
- Handy for asking what values a column actually contains.
Keywords and builtins used here
BYDISTINCTFROMORDERSELECT
The run, in numbers
- Lines
- 5
- Characters to type
- 66
- Tokens
- 11
- Three-star pace
- 70 tpm
At the three-star pace of 70 tokens a minute, this run takes about 9 seconds.
Step 5 of 5 in Selecting rows, step 5 of 23 in Language basics.