DISTINCT Predicate

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

Syntax

Form 1:

function DISTINCT (expression);

Form 2:

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

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 see whether two values or two row values 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;
  • select distinct c1.employee, firstname, salary
       from company as c1;

See Also

Statements:
Last updated: February 23, 2017