---
cuppy_hub: salesforce
cuppy_path: reference/official/data360/data-cloud-query-guide/references/dc-sql-reference/json-arrayagg.md
cuppy_section: docs
cuppy_doc: 1PCR-6Y08
cuppy_doc_uuid: 2596e920-f8dd-405d-8c4a-3d1c23e7b129
cuppy_permalink: https://cuppy.io/salesforce/d/1PCR-6Y08
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/json-arrayagg
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: 78211e1dc0cb531a6a4c012a56ddfea49953e6eb410f120c21225fd4d36aa4ae
# 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/json-arrayagg.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.

## `JSON_ARRAYAGG`

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

Aggregates the input values from a group into a JSON array, using an optional, user-supplied order.

*   `<value>`: The single expression collected into the JSON array.

*   `DISTINCT`: Keeps only distinct values. When you use `DISTINCT`, the `ORDER BY` expression (including its collation) must match `<value>`.
*   `ORDER BY <sort_expression> [, ...]`: Orders the elements within the array (an aggregate-local ordering). Each sort key accepts `ASC` / `DESC` and `NULLS FIRST` / `NULLS LAST`.
*   `ABSENT ON NULL`: Skips `NULL` inputs so they don’t appear in the array. This is the default.
*   `NULL ON NULL`: Keeps `NULL` inputs as JSON `null` elements.

A `json` value containing the aggregated array.

**Null handling:**

*   With the default `ABSENT ON NULL`, `NULL` inputs are dropped. A group whose values are all `NULL` returns an empty array (`[]`).
*   With `NULL ON NULL`, `NULL` inputs are kept as JSON `null` elements.

*   The [`FILTER` clause](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/filter-clause.html) isn’t supported for `json_arrayagg`.
*   If no `ORDER BY` is specified, the resulting array has an implementation-defined, non-deterministic order.
*   `json_arrayagg` with `ORDER BY` isn’t supported in combination with `ROLLUP`, `CUBE`, or `GROUPING SETS`.
*   The `<value>` is serialized to JSON using the [json_scalar](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-scalar.html) conversion rules.

Order elements by `id` and drop the `NULL` name (the default behavior).

Returns `["Ada","Grace"]`.

Use `NULL ON NULL` to retain `NULL` inputs as JSON `null` elements.

Returns `[20,null,30]`.

Build a JSON array of product names for each category.

*   [ARRAY_AGG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/array-agg.html)
*   [LISTAGG](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/listagg.html)
*   [JSON_SCALAR](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-scalar.html)
*   [JSON Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/json-funcs.html)
*   [Aggregate Functions](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/aggregate.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 -->
