如果使用大小写,则在bigquery中输出两行

时间:2018-05-21 10:39:31

标签: sql google-bigquery

当我运行此查询时,在同一日期的两个不同行中给出结果,其中包含零其他包含事件计数????     如何解决这个问题,任何帮助都会非常感激!

     (Select 
   distinct(case 
  when event_text = 'poll_vote' THEN device_id Else 0 END) as 
    pollvote,event_date from
  (Select event_date,event_text,count(distinct users) as device_id from
   (SELECT event.name as event_text,  ( user.value.value.string_value) 
    AS users,

    CAST(TIMESTAMP_ADD(TIMESTAMP_MICROS(event.timestamp_micros), 
    INTERVAL 330 MINUTE) AS date) AS event_date
  FROM
       `dataset.tablename`,
      UNNEST(event_dim) AS event,
      UNNEST(user_dim.user_properties) AS user
     where
         user.key="context_device_id" 
      GROUP BY
         event_date,event_text,users)
      GROUP BY
         event_text,event_date))

see the output image

1 个答案:

答案 0 :(得分:1)

仅将“ GROUP BY”用于event_date可以根据需要只给您一列。以下是一些GROUP BY示例。