Google bigquery 选择没有任何事件具有特定值的ID BigQuery
我的表中有FULLVISITORIDS,具有不同的VisitId和eventCategory 我想选择FullvisitorID,其中eventCategory中没有一个是“A” 例如: 从my_表中选择*Google bigquery 选择没有任何事件具有特定值的ID BigQuery,google-bigquery,Google Bigquery,我的表中有FULLVISITORIDS,具有不同的VisitId和eventCategory 我想选择FullvisitorID,其中eventCategory中没有一个是“A” 例如: 从my_表中选择* FullVisitorid Visitid .... .....hits.event.eventCategory 1 123 A
FullVisitorid Visitid .... .....hits.event.eventCategory
1 123 A
B
E
1 147 D
E
E
2 555 F
G
D
我只想要2作为我的最终输出
我尝试了以下代码,但似乎不起作用
Select fullvisitorid from `my_table` where fullvisitorid not in (select distinct fullvisitorid from
`my_table`, unnest(hits) hits where hits.event.eventCategory = 'A' )
谢谢你的帮助 以下查询获取嵌套命中记录中没有A的所有用户:
with all_visitors as (
-- Get a list of all FullVisitorid
select distinct FullVisitorid from `project.dataset.my_table`
),
eventCategory_As as (
-- Get a list of all FullVistiroid with A eventCategory
select distinct FullVistorid
from `project.dataset.my_table`
left join unnest(hits) h
where h.event.eventCategory = 'A'
)
-- Left join to get FullVisitorid who don't have an A eventCategory
select
a.FullVisitorid
from all_visitors a
left join eventCategory_As b on a.FullVistiorid = b.FullVisitorid
where b.FullVisitorid is null