【发布时间】:2020-01-27 23:42:23
【问题描述】:
我的 BigQuery 表如下所示
Fullvisitorid CustomDimension.Index CustomDimension.value
123 1 red
2 blue
3 green
456 1 red
3 orange
4 black
我希望我的最终输出如下所示
Fullvisitorid Color1 Color2
123 red green
456 red orange
以下是我编写的查询,但我收到错误“未找到函数:FIRST”
SELECT
fullvisitorid,
FIRST(IF(customDimensions.index=1, customDimensions.value, NULL)) color1,
FIRST(IF(customDimensions.index=3, customDimensions.value, NULL)) color2
FROM `my_table`
cross join
unnest(customDimensions) customDimensions,
unnest(hits) hits
where customDimensions.index in (1,3)
group by fullvisitorid
我发现了一个帮助我编写查询的类似问题:
[Transpose nested rows into columns in bigquery with google analytics data
我不确定为什么我的查询出现错误。 非常感谢任何帮助!
谢谢
【问题讨论】:
标签: google-bigquery transpose unnest