How To Use Distinct Clause In OraclePLSQL
Description
Distinct Clause is used to remove duplicates value from the results. This clause used with select statements in Oracle/PLSQL.
Syntax
The syntax for distinct Clause in oracle.
- Select
- Distinct Expression
- From
- Table
- Where
- condition;
Example
This example returns a single filed that removes duplicates from the results.
- select
- distinct Loc
- from
- Department
- where
- DEPT_NAME = 'RESEARCH DEPT';
Example
This example removes duplicate from more than one field in this statement.
- select
- distinct Loc,
- DEPT_NAME
- from
- Department
- where
- DEPT_ID > 30
- order By
- Loc;
Summary
Thus, we learnt, distinct clause is used to remove the duplicate value from the results and we learnt, how to use this clause with the examples.