`JSON_ARRAYAGG`

Data 360 Query Guide, mirrored from developer.salesforce.com: **Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

markdownreferencev11PCR-6Y08guide: data-cloud-query-guidestage: referencetrust: officialsource: developer.salesforce.comservice: data360interface: sql`JSON_ARRAYAGG`Data 360Data CloudData 360 Query Guide

Created 23 Oct 2026 · Modified 23 Oct 2026 · 1 version

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 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 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.

Read this document as markdown — the same bytes an agent receives.