SQL SELECT DISTINCT Clause

In previous SQL post we had discussed about DROP DATABASE Command and SQL SELECT Statement andSQL INSERT Statement and SQL UPDATE Statement and SQL WHERE Clause and SQL TOP 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 *

2 + 4 =


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">