Bird
0
0

Which of the following is the correct syntax to aggregate values into an array using ARRAY_AGG in PostgreSQL?

easy📝 Syntax Q12 of 15
PostgreSQL - Aggregate Functions and GROUP BY
Which of the following is the correct syntax to aggregate values into an array using ARRAY_AGG in PostgreSQL?
ASELECT ARRAY_AGG(column_name) FROM table_name;
BSELECT ARRAY_AGG column_name FROM table_name;
CSELECT ARRAY_AGG(column_name) table_name;
DSELECT ARRAY_AGG(column_name) FROM table_name WHERE;
Step-by-Step Solution
Solution:
  1. Step 1: Recall correct function call syntax

    ARRAY_AGG requires parentheses around the column name and a FROM clause.
  2. Step 2: Check each option

    SELECT ARRAY_AGG(column_name) FROM table_name; uses correct syntax with parentheses and FROM clause; others miss parentheses or have syntax errors.
  3. Final Answer:

    SELECT ARRAY_AGG(column_name) FROM table_name; -> Option A
  4. Quick Check:

    Correct ARRAY_AGG syntax uses parentheses and FROM [OK]
Quick Trick: Always use parentheses with ARRAY_AGG(column) [OK]
Common Mistakes:
  • Omitting parentheses around column_name
  • Leaving incomplete WHERE clause
  • Missing FROM keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PostgreSQL Quizzes