The distinct keyword is used with Select statement to retrieve unique values from the table. Distinct removes all the duplicate records while retrieving from database.
Syntax
Syntax
SELECT distinct column-name from table-name;
Example of Distinct keyword
Consider the following Student table.
s_id
|
s_Name
|
age
|
salary
|
101
|
Dashzin
|
15
|
5000
|
102
|
Ravi
|
18
|
4000
|
103
|
Abhinav
|
17
|
7000
|
104
|
Ankit
|
22
|
4000
|
105
|
Dashrath
|
17
|
5000
|
SELECT distinct salary from student;
The above query will return only the unique salary from student table
The above query will return only the unique salary from student table
salary
|
5000
|
4000
|
7000
|
0 comments:
Post a Comment