QuestenaPráctica que te muestra qué repasar después
Pregunta 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'Respuesta correcta

Explicación

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.

Continúa con este test

Empezar la práctica
Pregunta 20: In PostgreSQL 18, a group of three rows holds v values 1,… · SQL: NULL, Joins and Aggregates · Questena