To select information from a database without listing duplicates in the same column, use the SELECT DISTINCT statement in SQL.
Syntax:
1 |
SELECT DISTINCT <column name(s)> FROM <table name>
|
For the column name(s) field, enter the names of the columns you would like to pull the distinct data from in the table.
For the table name, enter the name of the table from which you are accessing the data.
Examples:
Suppose we have the following dataset in our database within a table named birthdays:
| FirstName | LastName | BirthDate |
| Brian | Johnson | 1/8/1975 |
| Nick | Thomson | 3/19/1965 |
| Tyler | Jones | 1/17/1994 |
| Ben | Thomson | 2/8/1987 |
To select distinct last ones, use the following query:
1 |
SELECT DISTINCT LastName FROM birthdays
|
Which would yield the following result set:
| LastName |
| Johnson |
| Thomson |
| Jones |





