JSON_AGG
JSONB_AGG
JSON_OBJECT_AGG
Aggregates values into a JSONB array.
JSONB_AGG(expr)
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;