DISTINCT Predicate

Specifies that only unique rows can appear in the result table.

Syntax

Form 1:

function DISTINCT (expression);

Form 2:

Form 3:

SELECT DISTINCT <select-list> FROM <table-expression>;

Arguments

function

can be any aggregate function.

expression

specifies any valid SQL expression.

See <sql-expression>
FedSQL Expressions

row-value constructor

specifies any row value expression that represents a row value.

See Row Value Expressions

SELECT <select-list> FROM <table-expression>

is a query that retrieves rows from a table.

See For more information about using the DISTINCT predicate in the SELECT statement, see the SELECT Clause.

Details

You can use the DISTINCT predicate to compare two values or two row values to see whether they are equal to one another. The DISTINCT predicate evaluates to true only if all rows that its subquery returns are distinct.
Note: Two null values are not considered distinct.

Example

  • select count(distinct avghigh) from worldtemps;
  • (42, 47,15) is distinct from (42, 47, 15)
  • select distinct c1.employee, firstname, salary
       from company as c1;

See Also

Statements: