Subscriber only lesson.
Sign up to this course to view this lesson.
Select Distinct allows us to return unique results.
When to use
Use it any time you want to find unique items.
Select Distinct looks like this:
SELECT DISTINCT [First Name]
This will return only the unique first names in the customer database. For example if there are 5 people named John and 3 people named Sally, each of these names will only be displayed once in the results (not 5 and 3 times).
You can also use COUNT to count the number of unique records.
SELECT COUNT ( DISTINCT [First Name] )
This will return the total number of unique first names in the customer database.
Hints & tips
- Select Distinct lets you return unique results
- Be sure to specify a column, it can't return wildcard *
Lesson notes are only available for subscribers.