COUNT(DISTINCT)

COUNT(DISTINCT column) counts the number of different non-null values in a column. It answers questions such as the number of distinct customers who ordered, where COUNT(*) would count all rows. It is more costly than a simple count on large volumes.

Example

SELECT COUNT(DISTINCT client_id) FROM commandes;

Related concepts

The whole glossary