Distinct keyword
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 for DISTINCT Keyword
SELECT distinct column-name from table-name;
Example
Consider the following Emp table.
eid | name | age | salary |
---|---|---|---|
401 | Anu | 22 | 5000 |
402 | Shane | 29 | 8000 |
403 | Rohan | 34 | 10000 |
404 | Scott | 44 | 10000 |
405 | Tiger | 35 | 8000 |
select distinct salary from Emp;
The above query will return only the unique salary from Emp table
salary |
---|
5000 |
8000 |
10000 |
No comments:
Post a Comment