Questenaتمرینی که نشان می‌دهد بعد چه چیزی را مرور کنید
سؤال 20

In PostgreSQL 18, a group of three rows holds v values 1, NULL and 2. What do array_agg(v) and string_agg(v::text, ',') return for that group?

  1. {1,2} and '1,2'
  2. {1,NULL,2} and '1,,2'
  3. NULL and NULL
  4. {1,NULL,2} and '1,2'پاسخ درست

توضیح

The two aggregates disagree on purpose: array_agg collects all input values including nulls, so the array has length 3, while string_agg concatenates only the non-null values and emits no separator for the missing one. Assuming both skip nulls is what makes an array and its string rendering fall out of alignment.

ادامهٔ این آزمون

شروع تمرین
سؤال 20: In PostgreSQL 18, a group of three rows holds v values 1,… · SQL: NULL, Joins and Aggregates · Questena