Reputation: 36166
I have a simple query like this:
SELECT container.category FROM `mybucket` as location
UNNEST location.partsContainers container
WHERE container.category IS NOT null
it gives me json:
[{
"category": "0028H3:WV CUTTING EDGE AXIAL REAM TRAY"
},
{
"category": "AVENTURA OASYS 1-2"
}, ... etc.
but what I need it a flat array of strings:
["0028H3:WV CUTTING EDGE AXIAL REAM TRAY",
"AVENTURA OASYS 1-2",
... etc
]
how can I achieve that?
Upvotes: 1
Views: 523
Reputation: 2445
you can use ARRAY_AGG:
SELECT RAW ARRAY_AGG(container.category)
FROM `mybucket` as location
UNNEST location.partsContainers container
WHERE container.category IS NOT null
Upvotes: 3