Quick Search:
 
 The Oracle DISTINCT Clause      [Return To Index] Jump to:  

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 |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org