Я просто пытаюсь решить простые примеры, чтобы улучшить мои навыки написания запросов в BigQuery.В приведенном ниже примере я не знаю, как удалить пустую строку.
with table1 as(
select "box_1" box, "yellow" colours union all
select "box_1" box, "green" colours union all
select "box_2" box, "blue" colours union all
select "box_2" box, "blue" colours union all
select "box_3" box, "red" colours union all
select "box_3" box, "green" colours union all
select "box_3" box, "blue" colours
)
select array(select box from unnest(x)y where "blue" in unnest(x) limit 1 )box_containing_blue
from(select box,array_agg(if(colours="blue",colours,null)ignore nulls )x
from table1 group by box)