PostgreSQLAggregate FunctionsJSONB_AGG
JSON_AGG

JSONB_AGGAggregate Functions

JSON_OBJECT_AGG

Aggregates values into a JSONB array.

Syntax

JSONB_AGG(expr)

Example

Enter values below to update the example in real time.

category
product_name
products
SELECT category, JSONB_AGG(product_name) AS products
FROM products
GROUP BY category;