我有一个简单的查询:
SELECT container.category FROM `mybucket` as location
UNNEST location.partsContainers container
WHERE container.category IS NOT null
它给了我json:
[{
"category": "0028H3:WV CUTTING EDGE AXIAL REAM TRAY"
},
{
"category": "AVENTURA OASYS 1-2"
}, ... etc.
但是我需要一个扁平的字符串数组:
["0028H3:WV CUTTING EDGE AXIAL REAM TRAY",
"AVENTURA OASYS 1-2",
... etc
]
我怎样才能做到这一点?
答案 0 :(得分:3)
你可以使用ARRAY_AGG:
SELECT RAW ARRAY_AGG(container.category)
FROM `mybucket` as location
UNNEST location.partsContainers container
WHERE container.category IS NOT null