我想查询我的数据集(表)以获取包含user_ids,日期,事件名称和事件参数键的列。我还指出我只想要'LeaveReview'事件。
fruit <- query_exec(
"SELECT user_dim.user_id, event.date, event.name, event_param.key,
FROM `table_201804*`,
UNNEST(event_dim) as event,
UNNEST(event.params) as event_param
WHERE event.name = 'LeaveReview'
AND _TABLE_SUFFIX BETWEEN '01' AND '25'
LIMIT 40",
project = "my_table"
)
我如何修改我的代码以仅获取那些在某一天同时执行“LeaveReview”和“ClickFavorite”的用户的信息?我尝试了以下方法,但这不起作用:
fruit <- query_exec(
"SELECT user_dim.user_id, event.date, event.name, event_param.key,
FROM `table_201804*`,
UNNEST(event_dim) as event,
UNNEST(event.params) as event_param
WHERE (event.name = 'LeaveReview' AND event.name = 'ClickFavorite')
AND _TABLE_SUFFIX BETWEEN '01' AND '25'
LIMIT 40",
project = "my_table"
)
如果我执行以下操作,我会让那些做过“ClickFavorite”活动但不是“LeaveReview”活动的人或其他方式:
fruit <- query_exec(
"SELECT user_dim.user_id, event.date, event.name, event_param.key,
FROM `table_201804*`,
UNNEST(event_dim) as event,
UNNEST(event.params) as event_param
WHERE (event.name = 'LeaveReview' OR event.name = 'ClickFavorite')
AND _TABLE_SUFFIX BETWEEN '01' AND '25'
LIMIT 40",
project = "my_table"
)
答案 0 :(得分:0)
嗯。这样的事情有用吗?
SELECT user_dim.user_id
FROM `table_201804*`,
UNNEST(event_dim) as event,
UNNEST(event.params) as event_param
WHERE event.name IN ('LeaveReview', 'ClickFavorite')
GROUP BY user_dim.user_id
HAVING COUNT(DISTINCT event.name) = 2;