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