SQL Dojo Bêta
Piège

COUNT(*) ou COUNT(colonne)

COUNT(colonne) ignore les NULL ; COUNT(*) compte les lignes.

Pour compter des lignes, COUNT(*). Réservez COUNT(colonne) à « les lignes où cette colonne est remplie », et COUNT(DISTINCT colonne) aux valeurs distinctes.

SELECT COUNT(*) AS all_rows,
       COUNT(city) AS with_city,
       COUNT(DISTINCT city) AS cities
FROM customers;
all_rowswith_citycities
40038227
L’essayer en Randori