DISTINCT Clause

The DISTINCT clause is used with the SELECT command to eliminate all duplicate rows from the result set. The DISTINCT clause can be used with more than one field.

DISTINCT clause guarantees that the resulting rows of the SELECT statement are unique. It returns only one copy of each set of duplicate rows selected. This clause appears immediately after the SELECT keyword. The syntax of using the DISTINCT clause is as follows:

SELECT DISTINCT columnname (s)
FROM tablename
WHERE [condition];

Note:

  1. Uniqueness is verified against the entire row, not against a specific column.
  2. DISTINCT clause cannot be specified, if the FROM clause contains LOB (Large Object) columns.
  3. Share

Leave a Reply