具有多个where子句的Bigquery列名

时间:2016-08-24 19:51:58

标签: google-bigquery

以下是我的要求。

产品是产品 count_group是计数大于100的groupname的计数 count_success是具有category = AAA和package ='BBB'的所有记录的总和。  count_user是userid列的exact_count_distinct,其category = AAA且package ='BBB'

enter image description here

下面的示例查询

    SELECT prod, 
count_group, 
Count_success, 
count_user
FROM
(SELECT
  prod,
  EXACT_COUNT_DISTINCT(group) AS count_group,
SUM(IF(categoty = 'AAA' AND package ='BBB', 1, 0)) AS Count_success,
  EXACT_COUNT_DISTINCT(userID) as count_user
 FROM
  [mytable]
WHERE
   Package ='FFF'

  AND (StartTime > ('2016-01-24 00:00:00 UTC')
    AND StartTime < ('2016-03-16 00:00:00 UTC')
    OR (StartTime > ('2016-03-26 00:00:00 UTC')
      AND StartTime < CURRENT_TIMESTAMP()))
      GROUP BY
  1
ORDER BY
  2 DESC IGNORE CASE)
WHERE Count_group >100  

0 个答案:

没有答案