Skip to content
masterclass Buddy

PostgreSQL · Function

jsonb_agg

jsonb_agg collects values from multiple rows into one JSONB array. It includes nulls and supports ordering inside the aggregate call.

Last updated

Syntax

jsonb_agg ( anyelement ORDER BY input_sort_columns ) → jsonb

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • json_agg
  • jsonb_agg_strict
  • jsonb_object_agg
  • to_jsonb
  • coalesce

Source: PostgreSQL: Documentation: 18: 9.21. Aggregate Functions. Checked 2026-11-03.