SQL TutorialLesson 4Free preview
SQL Select Distinct
This lesson is part of SQL · All levels
Summary
DISTINCT is used to eliminate duplicate values on the SELECT result. It's useful when you want to know a list of unique values, like the city where the customer came from. DISTINCT assesses the combinations of all selected columns, not each column separately.
Key points
- The SELECT DISTINCT column returns only a unique value to that column.
- In some columns, the combination of values that becomes the duplicate deletion reference.
- DISTINCT is placed right after the SELECT keyword.
- COUNT(DISTINCT column) calculates the number of unique values.
- Value NULL is considered a distinct duplicate group by DISTINCT.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.