When unique data is required, then we use disticnt keyword with the name of columns of a table.
it works automatically with single column or with multiple columns.
Syntax:
Select distinct column_name from table_name;
In the above query , only one column is used. we chek the it with example.
Example:
select distinct job from emp;
Result:
job
CLERK
SALESMAN
PRESIDENT
MANAGER
ANALYST
Now we see with the multiple columns
Example:
select distinct job,mgr from emp;
Result:
Job Mgr
CLERK 7902
PRESIDENT
CLERK 7698
CLERK 7788
CLERK 7782
SALESMAN 7698
MANAGER 7839
ANALYST 7566
You can chek result, Distinct statement retrive unique data from the multiple columns or from single column
No comments:
Post a Comment