SQL DISTINCT Statement:
This statement is used to show only DISTINCT values.
SELECT DISTINCT Statement:
In a table:
- A column contain many duplicate value and you want only different values from table.
- This statement retrieve only distinct(different) values.
Syntax:
SELECT DISTINCT column_name FROM table_name;
Table: 'Student'
StudentID | StudentName | Address | Country |
---|---|---|---|
1 | Ajay | Noida | India |
2 | Ajeet | Bareilly | India |
3 | Shivam | Nagaland | India |
Example:
SELECT DISTINCT Country
FROM Student;
The above SQL statement selects only distinct values from the "Country" columns from the "Student" table:
The above SQL statement selects only distinct values from the "Country" columns from the "Student" table:
After executing this statement, it result is
Country |
---|
India |
Conversion Conversion Emoticon Emoticon