DISTINCT in Aggregate Functions
By default, aggregate functions operate on all values supplied. You can use the DISTINCT keyword to eliminate duplicate values in aggregate function calculations.
Note: DISTINCT in the SELECT clause and DISTINCT in an aggregate function do not return the same result.
To avoid misleading results from a given SELECT statement, do not mix aggregate functions that include a DISTINCT clause and aggregate functions that do not include a DISTINCT clause. Either all of the aggregate functions in a SELECT statement, or none of them, should be used with a DISTINCT clause.
Syntax
aggregate-function ([ALL | DISTINCT] expression)
Example
SELECT COUNT (DISTINCT customer_id) FROM orders