首页 文章

大查询,错误:标量子查询生成多个元素

提问于
浏览
1

我有一个查询遇到此错误消息:错误:标量子查询生成多个元素

我想连接表示在不同时间段内发生的行为的表,但是正常连接似乎不起作用:

选择ag,count(*)from(select user_id as user,(选择x.value.string_value from analytics_156934592.events_20180701,unnest(event_params)as x,其中x.key ='group')为g,(选择x.value .string_value来自analytics_156934592.events_20180701,unnest(event_params)为x,其中x.key ='operation')作为来自analytics_156934592.events_20180701的操作,其中event_name ='book_now')一个连接(选择user_id作为用户,(选择x.value.string_value)来自analytics_156934592.events_20180702,unnest(event_params)为x,其中x.key ='operation')作为来自analytics_156934592.events_20180702的操作,其中event_name ='book_now')b on a.user = b.user,其中a.operation ='no_car'和b.operation ='确认'组由ag

不确定它是否是与Big Query Standard Sql连接的正确方法此外,以前类似问题的解决方案对我不起作用 .

谢谢你的帮助!

1 回答

  • 1

    谢谢大家!

    我从朋友那里得到了解决方案,这是可行的:

    select count(distinct a.user), count(distinct b.user_id)
    from
    
    (select
    user_id as user
    
    from `analytics_156934592.events_20180707`
    join unnest(event_params) as x
    join unnest(event_params) as y
    where event_name = 'book_now'
    and x.key = 'group'
    and x.value.string_value = 'a'
    and y.key = 'operation'
    and y.value.string_value = 'no_car')a 
    
    left join
    
    (select
    user_id , event_date
    
    from `analytics_156934592.events_*` 
    join unnest(event_params) as y
    where event_name = 'launcher'
    and y.key = 'operation'
    and y.value.string_value = 'show'
    AND REGEXP_EXTRACT(_TABLE_SUFFIX, r'(\d+)') BETWEEN '20180708' and '20180720')b 
    
    on a.user = b.user_id
    

相关问题