Examples of the COUNT DISTINCT Function
In the next example, the user wants to know how many unique non-NULL values are in the ship_instruct column of the orders table. The user calls the COUNT DISTINCT function in the projection list of the SELECT statement:
SELECT COUNT(DISTINCT ship_instruct) AS unique_notnulls FROM orders;
The following table shows the result of this query.
unique_notnulls |
---|
16 |