---
cuppy_hub: salesforce
cuppy_path: reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/aggregate.md
cuppy_section: docs
cuppy_doc: NQJH-BKH6
cuppy_doc_uuid: 8ccec741-7cd0-4fc2-baea-28ea9bfd7efa
cuppy_permalink: https://cuppy.io/salesforce/d/NQJH-BKH6
cuppy_version: 1
cuppy_updated: 2026-10-23T16:16:52.575Z
cuppy_canonical: https://cuppy.io/salesforce/docs/reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/aggregate
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: 3648033cf895c1718959af7c04d59cd1323c8d2429920bb92d47b77c28b24b6a
# cuppy_body_sha256 is over the document body ALONE, excluding both generated blocks.
---

> Mirror of <https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/aggregate.html> (Salesforce, Data 360 Query Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.

## Aggregate Functions

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Functions that compute a single result from a set of input values. Use aggregate functions to:

*   **Summarize data** by computing counts, sums, and averages.
*   **Analyze distributions** with statistical functions such as standard deviation and variance.
*   **Find extremes** with MIN and MAX values.
*   **Compute percentiles** and identify modes in datasets.
*   **Collect values** into an array, a delimited string, or a JSON array.

*   **Null handling**: Except for `COUNT`, `ARRAY_AGG` and `JSON_ARRAYAGG`, aggregate functions return NULL when no rows match. Use `coalesce(aggregate_func(...), default_value)` to substitute a default value.
*   **Group by requirement**: Non-aggregated fields in the `SELECT` clause must appear in the `GROUP BY` clause.
*   **Filter clause**: Use the [FILTER clause](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/filter-clause.html) to apply conditions to individual aggregates.

Common aggregate functions for summarizing data:

*   [ANY_VALUE](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/any-value.html) - Return an arbitrary value from the group.
*   [APPROX_COUNT_DISTINCT](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/approx-count-distinct.html) - Compute an approximate count of distinct values.
*   [AVG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/avg.html) - Calculate the arithmetic mean.
*   [BIT_AND](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/bit-and.html) - Compute bitwise AND of all values.
*   [BIT_OR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/bit-or.html) - Compute bitwise OR of all values.
*   [BOOL_AND](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/bool-and.html) - Return `true` if all values are true.
*   [BOOL_OR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/bool-or.html) - Return `true` if any value is true.
*   [COUNT](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/count.html) - Count rows or non-null values.
*   [MAX](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/max.html) - Find the maximum value.
*   [MAX_BY](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/max-by.html) - Return the value from the row with the maximum key.
*   [MIN](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/min.html) - Find the minimum value.
*   [MIN_BY](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/min-by.html) - Return the value from the row with the minimum key.
*   [SUM](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/sum.html) - Calculate the total.

Functions for statistical analysis:

*   [CORR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/corr.html) - Compute correlation coefficient.
*   [COVAR_POP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/covar-pop.html) - Compute population covariance.
*   [COVAR_SAMP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/covar-samp.html) - Compute sample covariance.
*   [KURTOSIS](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/kurtosis.html) - Compute unbiased excess kurtosis.
*   [SKEWNESS_POP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/skewness-pop.html) - Compute population skewness.
*   [SKEWNESS_SAMP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/skewness-samp.html) - Compute sample skewness.
*   [STDDEV_POP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/stddev-pop.html) - Compute population standard deviation.
*   [STDDEV/STDDEV_SAMP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/stddev.html) - Compute sample standard deviation.
*   [VAR_POP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/var-pop.html) - Compute population variance.
*   [VARIANCE/VAR_SAMP](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/variance.html) - Compute sample variance.

Cast the input of an aggregate function to force a different output type. For example, use `var_pop(CAST(A AS DOUBLE PRECISION))` to get a `double precision` result.

Functions that combine values from a group into a single array, string, or JSON array:

*   [ARRAY_AGG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-agg.html) - Collect values into an array, with optional ordering and NULL handling.
*   [JSON_ARRAYAGG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-arrayagg.html) - Collect values into a JSON array, with optional ordering and NULL handling.
*   [LISTAGG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/listagg.html) - Concatenate values into a single delimited string.

Aggregate functions that use the `WITHIN GROUP` syntax:

*   [FIRST_VALUE](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/first-value-ordered-set.html) - Return the `<value>` from the first row within each `GROUP BY` group after ordering by specified keys.
*   [MODE](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/mode.html) - Return the most frequent value.
*   [PERCENTILE_CONT](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/percentile-cont.html) - Compute continuous percentile with interpolation.
*   [PERCENTILE_DISC](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/percentile-disc.html) - Compute discrete percentile without interpolation.

For `MODE`, `PERCENTILE_CONT`, and `PERCENTILE_DISC`, NULL values in the sorted input are ignored where noted on each function page. Percentile functions require a fraction between 0 and 1. `FIRST_VALUE` does not use a fraction. Ordering follows the `ORDER BY` keys and `NULLS FIRST` / `NULLS LAST` modifiers.

*   [GROUPING](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/grouping.html) - Identify which columns are aggregated in grouping sets.
*   [FILTER Clause](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/filter-clause.html) - Filter rows passed to aggregate functions.

Calculate summary statistics.

Summarize data by category.

Compute multiple filtered aggregates in one query.

Compute standard deviation and variance.

Find median and quartiles.

*   [GROUP BY Clause](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/select-group-by.html)
*   [Window Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/window.html)


---
<!-- cuppy -->
You are reading one file. The same content is free over MCP at https://cuppy.io/mcp with no signup: ranked search across all 376 documents in this hub, the merged view when you work in a layer, known workarounds matched to the error you hit, and depth control so you spend tokens on what you need. Start with the `_hello` tool. How to connect: https://cuppy.io/salesforce/ Something wrong in this document? Report it with the `session feedback` tool on the same endpoint.
<!-- /cuppy -->
