Background documentationDISTINCT Specification (distinct_spec) Locate this document in the navigation structure

 

The DISTINCT specification (distinct_spec) is specified in a QUERY specification (QUERY expression) or in a SINGLE SELECT statement to remove duplicate rows.

Structure

Syntax Syntax

  1. <distinct_spec> ::=
      DISTINCT
    | ALL
End of the code.
Examples

SQL Tutorial, Selecting and Arranging Rows

Explanation

A row is a duplicate of another row if both have identical values in each column. NULL values are assumed to be identical, as are special NULL values.

If no DISTINCT specification is specified, no duplicate rows are removed from the result table.

  • DISTINCT: All duplicate rows are removed from the result table.

  • ALL: No duplicate rows are removed from the result table.