Distinct clause is used to exclude duplicate records from the result set.
SYNTAX:
SELECT DISTINCT Column1, Column2, Column3
FROM Table1
Table: Employee
EmployeeID FirstName LastName Title HireDate ManagerID
1 George Cruz CEO 12/8/2008 NULL
2 John Mathew Vice President 4/1/2009 1
3 Ethan William Director I 8/8/2009 2
4 Jacob Logan Director II 12/8/2011 3
5 Nathan Mateo Senior Manager 9/3/2009 4
6 Alice Charles Manager I 12/8/2012 5
7 John Robert Manager II 10/8/2011 6
8 Sophia James Manager III 5/8/2011 7
9 Kevin Chan Product Manager 7/8/2011 5
10 Susan Mortiz Solutions Arthitect 1/3/2012 6
11 Martha Miller Systems Arthitect 12/15/2012 10
Example
Query :
SELECT DISTINCT FirstName
FROM Employee
Output :
FirstName
Alice
Ethan
George
Jacob
John
Kevin
Martha
Nathan
Sophia
Susan
Description :
The above query uses DISTINCT clause to remove duplicate data from the query output. Notice that John appears twice in the Employee table, but with DISTINCT clause, John appears in the above result set only once.