Verified across all 11 dialects: MySQL, MariaDB, PostgreSQL, MSSQL,
Oracle, SQLite, CockroachDB, Redshift, Db2, and Snowflake all support the
exact ANSI COUNT(DISTINCT expr) syntax. ClickHouse also parses
COUNT(DISTINCT expr) (it desugars to an internal uniq-exact
implementation), though ClickHouse users may prefer the native
uniqExact(expr) function for clarity/performance on very large
cardinalities — that's a deliberate escape hatch, not a requirement, so
COUNT(DISTINCT expr) is used here for consistency with the other
dialects.
COUNT(DISTINCT expr).Verified across all 11 dialects: MySQL, MariaDB, PostgreSQL, MSSQL, Oracle, SQLite, CockroachDB, Redshift, Db2, and Snowflake all support the exact ANSI
COUNT(DISTINCT expr)syntax. ClickHouse also parsesCOUNT(DISTINCT expr)(it desugars to an internal uniq-exact implementation), though ClickHouse users may prefer the nativeuniqExact(expr)function for clarity/performance on very large cardinalities — that's a deliberate escape hatch, not a requirement, soCOUNT(DISTINCT expr)is used here for consistency with the other dialects.