«Back to Home

Oracle Jump Start

Topics

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.
  1. Select  
  2. Distinct Expression  
  3. From  
  4. Table  
  5. Where  
  6. condition;  
Example
 
This example returns a single filed that removes duplicates from the results.
  1. select  
  2. distinct Loc  
  3. from  
  4. Department  
  5. where  
  6. DEPT_NAME = 'RESEARCH DEPT';  
1 
 
Example
 
This example removes duplicate from more than one field in this statement.
  1. select  
  2. distinct Loc,  
  3. DEPT_NAME  
  4. from  
  5. Department  
  6. where  
  7. DEPT_ID > 30  
  8. order By  
  9. Loc;  
2 
 
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.