我有一个带架构的bigquery表:
我想得到这个结果:
flow_timestamp, channel_name, number_of_digits
2019-10-31 15:31:15, channel_name_1, 3,
2019-10-31 15:31:15, channel_name_2, 4,
:
:
我的查询:SELECT flow_timestamp, timeseries.channel_name, MAX(IF(channel_properties.key = 'number_of_digits', channel_properties.value, NULL)) AS number_of_digits FROM my_table , unnest(timeseries.channel_properties) as channel_properties
我尝试了此处显示的相同技术, How to aggregate multiple rows into one in BigQuery?
但出现错误SELECT list expression references column flow_timestamp which is neither grouped nor aggregated at [1:8]
答案 0 :(得分:1)
以下是用于BigQuery标准SQL
#standardSQL
SELECT
flow_timestamp,
timeseries.channel_name,
( SELECT MAX(IF(channel_properties.key = 'number_of_digits', channel_properties.value, NULL))
FROM UNNEST(timeseries.channel_properties) AS channel_properties
) AS number_of_digits
FROM my_table