SQL aggregation functions

    You can use aggregation functions in the SELECT clause of any Druid SQL query.

    Filter any aggregator using the FILTER clause, for example:

    The FILTER clause limits an aggregation query to only the rows that match the filter. Druid translates the FILTER clause to a native . Two aggregators in the same SQL query may have different filters.

    • When using filtered aggregations within a grouping.

    The initial value varies by aggregator. and the approximate count distinct sketch functions always return 0 as the initial value.

    In the aggregation functions supported by Druid, only COUNT, ARRAY_AGG, and STRING_AGG accept the DISTINCT keyword.

    The order of aggregation operations across segments is not deterministic. This means that non-commutative aggregation functions can produce inconsistent results across the same query.

    These functions create sketch objects that you can use to perform fast, approximate analyses. For advice on choosing approximate aggregation functions, check out our . To operate on sketch objects, also see the DataSketches post aggregator functions.

    Load the DataSketches extension to use the following functions.

    Load the DataSketches extension to use the following functions.

    Load the T-Digest extension to use the following functions. See the for additional details and for more information on these functions.