答案 0 :(得分:3)
下面是BigQuery Standard SQL,它为您提供超过90个“筹码”和超过1000个“硬币”的所有行。
#standardSQL
SELECT *
FROM yourTable
WHERE (
SELECT COUNTIF((key = 'chips' AND value.int_value > 90)
OR (key = 'coins' AND value.int_value > 1000))
FROM UNNEST(event_dim.params)
) > 1
注意:上面的查询假设每行中的键唯一性 - 这很可能是一种情况。
以下版本为您提供了超过90个“筹码”和超过1000个“硬币”的各行的所有级别和数量
#standardSQL
SELECT param.value.int_value, COUNT(1) AS cnt
FROM yourTable, UNNEST(event_dim.params) AS param
WHERE (
SELECT COUNTIF((key = 'chips' AND value.int_value > 90)
OR (key = 'coins' AND value.int_value > 1000))
FROM UNNEST(event_dim.params)
) > 1
AND param.key = 'level'
GROUP BY 1
答案 1 :(得分:2)
这可能会对您有所帮助:
SELECT
*
FROM data
WHERE ((SELECT COUNTIF((key = 'chips' AND value.int_value > 90)) FROM UNNEST(event_dim.params)) > 0 AND (SELECT countif((key = 'coins' AND value.int_value > 1000)) FROM UNNEST(event_dim.params)) > 0)
数据是您的输入行:
WITH data AS(
SELECT STRUCT<name string, params ARRAY<struct<key string, value STRUCT<string_value string, int_value int64> >>> ('level_up', [STRUCT('level' as key, STRUCT('null' as string_value, 19 as int_value) as value), STRUCT('firebase_event_origin' as key, struct('app' as string_value, null as int_value) as value), struct('chips' as key, STRUCT('null' as string_value, 97 as int_value) as value), STRUCT('coins' as key, struct('null' as string_value, 4085 as int_value) as value), STRUCT('powerups' as key, STRUCT('null' as string_value, 19 as int_value) as value)]) event_dim
)
请注意,这是使用BigQuery的Standard SQL版本。
答案 2 :(得分:0)
这是针对Firebase BigQuery分析的修改版:
UserModule