SQL SELECT DISTINCT Clause



In this sql tutorial we will learn how to use Distinct clause with example.

SQL DISTINCT Clause

SQL DISTINCT Clause : The sql Distinct clause is used to remove duplicate records from the result of sql select statement.

The SQL DISTINCT Clause Syntax

SELECT  DISTINCT  Col1, Col2  FROM  table_name

table_name – is the name of table from records to be  retrieved.
Col1,Col2 – name of the column name which will be selected.
Distinct – is the clause to remove duplicate records in col1 and col2 in results.

 

SQL DISTINCT Clause Example :

Here, we have table Student with below records.

The SQL Student Table :

ID Name City Email
1 Meera Bombay meera@yahoo.com
2 Ram Surat ram@yahoo.com
3 Meera Bombay jay@yahoo.com
4 Vaidehi Ahmedabad meera@yahoo.com

 

SELECT DISTINCT Name FROM Student

Name
Meera
Ram
Vaidehi

Leave a Reply

Your email address will not be published. Required fields are marked *