Italian Trulli

SQL SELECT DISTINCT Statement

Test Tribe
.
SELECT DISTINCT In SQL 

Distinct means different, In Sql, a distinct (different) query is used to avoid duplicate values. A table may contain duplicate values if you want only distinct values then use the DISTINCT  Statement.

Syntax of SELECT DISTINCT  
The basic syntax for the SELECT DISTINCT is as follows


SELECT DISTINCT Columnname FROM TableName;


Note: SQL SELECT DISTINCT can be used with COUNT.


SELECT COUNT (DISTINCT Columnname) FROM TableName;


Example of SELECT DISTINCT 

SELECT DISTINCT StudentName  FROM Student ;


In the Above Example, It Will Select all the Distinct values from studentname column in the student table.


SELECT COUNT (DISTINCT StudentName) FROM Student;

In the Above Example, It Will display the count of all student.
Result- 6


Hope !!! The above tutorial on SELECT DISTINCT is helpful for you...

Team,
QA acharya

Sql distinct statement with Example

Post a Comment

0 Comments