The DISTINCT function is a
set function that removes duplicated values and all NULL values.Syntax
<distinct_function>::= <set_function_name> ( DISTINCT <expression> )
set_function_name, expressionExplanation
The argument of a DISTINCT function is a set of values that is calculated as follows:
The DISTINCT function is executed taking into account the relevant set function name for this set of values.
Result of the DISTINCT function | |
Set of values is empty and the DISTINCT function is applied to the entire result table |
The set functions AVG, MAX, MIN, STDDEV, SUM, VARIANCE supply the NULL value as their result. The set function COUNT supplies the value 0. |
There is no group to which the DISTINCT function can be applied. |
The result is an empty table. |
The set of values contains at least one special NULL value. |
Special NULL value |
Model table:
customerIn how many cities do the customers live?
SELECT COUNT(DISTINCT city) number_cities FROM customer
NUMBER_CITIES |
6 |