March 2001
Intermediate to advanced
640 pages
14h 9m
English
The last element we'll learn about today is the DISTINCT keyword. DISTINCT asks SQL Server to remove all duplicate rows from your result set.
Most of the time, you won't need to use DISTINCT. Sometimes, when you think you need DISTINCT you really have a problem somewhere else in your code. But there are legitimate situations where duplicate rows can emerge from a table. In the next pages, we'll learn how to use DISTINCT and how to avoid it.
The keyword DISTINCT is placed optionally between SELECT and the select list. When you include DISTINCT, the server removes duplicate rows from your results.
What if you wanted a list of countries where you have suppliers? Consider this query:
select ...
Read now
Unlock full access