Aggregation & GROUP BY
Exercise · SQL & Querying

Predict, then run it

Predict the output

coats(tag) = red, NULL, NULL. Count coats per tag, labelling the untagged group so it can't render blank:

SELECT COALESCE(tag, '<untagged>') AS tag, COUNT(*) AS n FROM coats GROUP BY tag ORDER BY tag NULLS LAST;

Predict the exact output.