Skip to main content

Aggregation Functions

Aggregation functions are used within summarize operators to compute values across groups of rows. Most common aggregations — count(), sum(), avg(), min(), max() — work across all dialects. More advanced aggregations like arg_max(), percentile(), dcountif(), and make_bag() are ClickHouse-only or have limited availability.

Legend: ✅ Supported · ⚠️ Approximated · ❌ Not Supported · 🔄 Rewritten

FunctionSQLiteMySQLClickHousePostgreSQLNotes
count()
countif()Non-ClickHouse: SUM(CASE WHEN ...)
sum()
sumif()Non-ClickHouse: SUM(CASE WHEN ...)
avg()
avgif()Non-ClickHouse: AVG(CASE WHEN ...)
min()
minif() / min_if()
max()
maxif() / max_if()
dcount()ClickHouse: uniq(); others: COUNT(DISTINCT ...)
dcountif()ClickHouse: uniqIf()
any() / take_any()⚠️⚠️⚠️KQL returns an arbitrary value. Non-ClickHouse: MIN() used as a deterministic placeholder — results may differ since MIN() imposes ordering. Use ANY_VALUE() on MySQL 8.0+ if available
anyif()Non-ClickHouse: MIN(CASE WHEN ...)
arg_max()ClickHouse: argMax()
arg_min()ClickHouse: argMin()
stdev()ClickHouse: stddevPop()
stdevif()
variance()ClickHouse: varPop()
varianceif()
percentile()ClickHouse: quantile(); Postgres: percentile_cont() WITHIN GROUP
percentiles()⚠️Postgres: expands to single percentile_cont with warning
hll()ClickHouse: uniqHLL12(); others: COUNT(DISTINCT ...)
hll_merge()
tdigest() / tdigest_merge()ClickHouse: quantileTDigest()
make_list()
make_set()ClickHouse: groupUniqArray
make_bag()ClickHouse: groupArray()
coalesce()COALESCE()
nullif()NULLIF()
case()CASE WHEN ... END
iif() / iff()ClickHouse: if(); others: CASE WHEN