GROUP BY
GROUP BY id is supported and groups by document id. On large tables, that can produce one group per row.
Global count
id.
WHERE
=, !=, <, <=, >, >=.
IN, BETWEEN, LIKE
NOT BETWEEN and NOT LIKE are supported. LIKE uses % (any run) and _ (single char) and is case-sensitive.
Aggregates
| Function | Example |
|---|---|
COUNT(*) | SELECT tag, COUNT(*) FROM t GROUP BY tag |
SUM(col) | SELECT tag, SUM(score) FROM t GROUP BY tag |
AVG(col) | SELECT tag, AVG(score) FROM t GROUP BY tag |
MIN(col) | SELECT tag, MIN(score) FROM t GROUP BY tag |
MAX(col) | SELECT tag, MAX(score) FROM t GROUP BY tag |
Aggregate over a function
Aggregates can wrap a scalar function:Aliases
Name the output value column withAS:
GROUP BY a function
Group by a computed key, e.g. bucket timestamps by month:HAVING
Filter groups after aggregation. Reference the aggregate value column by its output name (count, sum_<col>, avg_<col>, …, or an alias) or the group key column:
IN, BETWEEN, and LIKE are supported in HAVING. Use the value column name (count, sum_score) — not the COUNT(*)/SUM(...) expression.
