Bird
0
0

What is the main purpose of the JSON_AGG function in PostgreSQL?

easy📝 Conceptual Q1 of 15
PostgreSQL - Aggregate Functions and GROUP BY
What is the main purpose of the JSON_AGG function in PostgreSQL?
ATo convert JSON data into text format
BTo aggregate multiple rows into a single JSON array
CTo filter JSON objects based on a condition
DTo update JSON fields in a table
Step-by-Step Solution
Solution:
  1. Step 1: Understand JSON_AGG functionality

    The JSON_AGG function collects multiple rows and combines them into a single JSON array.
  2. Step 2: Compare options with function purpose

    Only To aggregate multiple rows into a single JSON array correctly describes this aggregation behavior, while others describe unrelated JSON operations.
  3. Final Answer:

    To aggregate multiple rows into a single JSON array -> Option B
  4. Quick Check:

    JSON_AGG purpose = aggregate rows into JSON array [OK]
Quick Trick: JSON_AGG collects rows into one JSON array [OK]
Common Mistakes:
  • Confusing JSON_AGG with JSON functions that modify or filter data
  • Thinking JSON_AGG returns a single JSON object instead of an array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes