Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle DISTINCT Clause      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: DISTINCT

Definition:
The DISTINCT clause acts as a filter to remove duplicate records from a result set. It ensures that any records that are returned are unique for the column or columns specified in the SELECT statement. A duplicate row is defined as a row with matching values for each expression in the SELECT list. The DISTINCT keyword is synonymous with the UNIQUE keyword, which is non-standard SQL. Do not use "UNIQUE".

Note that the DISTINCT clause can only be used with select statements; it cannot be used in INSERT, UPDATE, or DELETE statements. You also cannot specify DISTINCT if the SELECT list contains LOB columns.

Example Syntax:

SELECT DISTINCT column_name(s) ... 
FROM table_name(s)
WHERE (predicates);


Example Usage:
Multiple column names (and tables) may be specified in the SELECT statement. This example will select a list of unique last names in each state:

SELECT DISTINCT state, last_name
FROM users;


Related Links:

Related Code Snippets:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 112 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?