The DISTINCT keyword is optional with SUM, AVG, and COUNT. When you use DISTINCT, duplicate values are eliminated before calculating the sum, average, or count.
For example, to find the number of different cities in which there are contacts, enter:
SELECT COUNT( DISTINCT City ) FROM Contacts;
You can use more than one aggregate function with DISTINCT in a query. Each DISTINCT is evaluated independently. For example:
SELECT COUNT( DISTINCT GivenName ) "first names", COUNT( DISTINCT Surname ) "last names" FROM Contacts;
|first names||last names|