Nov 06

The SQL DISTINCT clause is used together with the SQL SELECT statement, to return a dataset with unique entries for certain database table column.

In a table, some of the columns may contain duplicate values. This is not a problem but sometimes you will want to list only the different (distinct) values in a table. The SQL DISTINCT clause can be used to return only distinct (different) values.

SELECT DISTINCT column_name(s) FROM table_name

We will use our Customers database table to illustrate the usage of the SQL DISTINCT clause.

LName FName Email
John Smith John.Smith@yahoo.com
Steven Goldfish goldfish@gmail.com
Paula Kari pb@plasa.com
James Smith jim@yahoo.co.uk

For example if we want to select all distinct FName from our Customers table, we will use the following the SQL DISTINCT clause:

SELECT DISTINCT FName FROM Customers

The result of the SQL DISTINCT clause expression above will look like this:

FName
Smith
Goldfish
Kari

Incoming search terms for the article:

sql distinct hora

Leave a Reply

Features Stats Integration Plugin developed by YD