What does SELECT DISTINCT country FROM users; return?
Options
- Every row's country, duplicates included
- Each country only once (Correct option)
- The number of countries
- The first country
Answer
Each country only once
Why
DISTINCT removes duplicate rows from the result. If 100 users are from Peru, 'Peru' appears once.
To count the different values: SELECT COUNT(DISTINCT country) FROM users;.
Remember
DISTINCT = unique values only.