答案 0 :(得分:2)
您可以使用以下方法修复语法:
SELECT DISTINCT geoNetwork.country
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`
WHERE _TABLE_SUFFIX BETWEEN '20170701' AND '20170701' AND
hits[offset(0)].hour > 11
但那并不能真正做到你想要的。相反,您需要unnest()
,因为hits
是一个数组。所以:
SELECT DISTINCT geoNetwork.country
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`,
unnest(hits) hit
WHERE _TABLE_SUFFIX BETWEEN '20170701' AND '20170701' and
hit.hour > 11;
另请注意,hour
似乎是一个数字,因此单引号不合适。
答案 1 :(得分:2)
#standardSQL
SELECT DISTINCT geoNetwork.country
FROM `bigquery-public-data.google_analytics_sample.ga_sessions_*`
WHERE _TABLE_SUFFIX BETWEEN '20170701' AND '20170701'
AND EXISTS (SELECT 1 FROM UNNEST(hits) hit WHERE hit.hour > 11)