Google bigquery 为什么我的BigQuery查询返回的日期与我在WHERE子句中指定的日期不同?
我有下面的问题。我只希望它返回WHERE子句中指定的日期,但是它返回的是所有数据。我已经尝试使用Google bigquery 为什么我的BigQuery查询返回的日期与我在WHERE子句中指定的日期不同?,google-bigquery,Google Bigquery,我有下面的问题。我只希望它返回WHERE子句中指定的日期,但是它返回的是所有数据。我已经尝试使用\u TABLE\u后缀作为日期,但没有成功。我还能做什么 SELECT date, 'iOS' as app_source, h.eventinfo.eventlabel, COUNT(1) events, COUNT(DISTINCT CONCAT(fullvisitorid, CAST(visitstarttime AS string))) uniqueEvents FROM
\u TABLE\u后缀作为日期,但没有成功。我还能做什么
SELECT
date,
'iOS' as app_source,
h.eventinfo.eventlabel,
COUNT(1) events,
COUNT(DISTINCT CONCAT(fullvisitorid, CAST(visitstarttime AS string))) uniqueEvents
FROM
`XXXX1.ga_sessions_*`,
UNNEST(hits) h
WHERE
h.type='EVENT'
and (h.eventInfo.eventCategory = 'Live' and h.eventInfo.eventLabel = 'Team Chat')
or (h.eventInfo.eventCategory = 'Messages' and h.eventInfo.eventLabel = 'Direct Message')
and date >= "20190818"
GROUP BY
1,2,3
UNION ALL
SELECT
date,
'Android' as app_source,
h.eventinfo.eventlabel,
COUNT(1) events,
COUNT(DISTINCT CONCAT(fullvisitorid, CAST(visitstarttime AS string))) uniqueEvents
FROM
`XXXX2.ga_sessions_*`,
UNNEST(hits) h
WHERE
h.type='EVENT'
and (h.eventInfo.eventCategory = 'Live' and h.eventInfo.eventLabel = 'Team Chat')
or (h.eventInfo.eventCategory = 'Messages' and h.eventInfo.eventLabel = 'Direct Message')
and date >= "20190818"
GROUP BY
1,2,3
ORDER BY
date
您应该修复WHERE子句,如下例所示
WHERE
h.type='EVENT'
and (
(h.eventInfo.eventCategory = 'Live' and h.eventInfo.eventLabel = 'Team Chat')
or (h.eventInfo.eventCategory = 'Messages' and h.eventInfo.eventLabel = 'Direct Message')
)
and date >= "20190818"