I'm trying to make a query in BigQuery with the nested ARRAY_AGG function (one inside the other), as follows:
ARRAY_AGG(
STRUCT(
.
.
.
.
.
ARRAY_AGG(
STRUCT(
.
)
) as xxx
)
) as xxx
However, I am getting the following error:
Aggregations of aggregations are not allowed at [44:3]
How can I rewrite this BigQuery query to return an aggregation of one category with the other in the BigQuery output JSON?
I tried to guide myself by the following Medium article:
https://towardsdatascience.com/bigquery-creating-nested-data-with-sql-727b761f1755
But I am unexpectedly getting some different types of errors when trying to return the aggregation in other ways.