SQL Distinct
We will
use the Northwind database table to illustrate the usage of SQL
DISTINCT
|
EmployeeID |
|
LastName |
FirstName |
Title |
TitleOfCourtesy |
BirthDate |
|
1 |
|
Davolio |
Nancy |
Sales Representative |
Ms. |
12/8/1948 |
|
2 |
|
Fuller |
Andrew |
Vice President, Sales |
Dr. |
2/19/1952 |
|
3 |
|
Leverling |
Janet |
Sales Representative |
Ms. |
8/30/1963 |
|
4 |
|
Peacock |
Margaret |
Sales Representative |
Mrs. |
9/19/1937 |
|
5 |
|
Buchanan |
Steven |
Sales Manager |
Mr. |
3/4/1955 |
|
6 |
|
Suyama |
Michael |
Sales Representative |
Mr. |
7/2/1963 |
|
7 |
|
Fuller |
Robert |
Sales Representative |
Mr. |
5/29/1960 |
|
8 |
|
Callahan |
Laura |
Inside Sales Coordinator |
Ms. |
1/9/1958 |
|
9 |
|
Dodsworth |
Anne |
Sales Representative |
Ms. |
1/27/1966 |
|
SELECT DISTINCT LastName
FROM Employees
|
The result:
Buchanan
Callahan
Davolio
Dodsworth
Fuller
Leverling
Peacock
Suyama
|