Google bigquery #standardsql Bigquery中的会话数

Google bigquery #standardsql Bigquery中的会话数,google-bigquery,bigquery-standard-sql,Google Bigquery,Bigquery Standard Sql,我希望将这个Bigquery#legacySQL查询转换为#standardsql #legacySQL SELECT SUM(totals.visits) AS Sessions, COUNT(DISTINCT(fullVisitorID), 2000000) as Distinct_Users #this doesn't include null values and I've increased the sample size to 2000000 (Learn more) FROM T

我希望将这个Bigquery#legacySQL查询转换为#standardsql

#legacySQL
SELECT SUM(totals.visits) AS Sessions, 
COUNT(DISTINCT(fullVisitorID), 2000000) as Distinct_Users #this doesn't include null values and I've increased the sample size to 2000000 (Learn more)
FROM TABLE_DATE_RANGE([0123456789.ga_sessions_],TIMESTAMP('2017-01-01'),TIMESTAMP('2017-03-13'))
到目前为止,我获得了正确的用户数,但仍在努力获得正确的会话数:

#standardsql
SELECT 
count(distinct fullvisitorid)
,SUM(totals.visits) AS Sessions
FROM `ga-export-1111.0123456789.ga_sessions_2017*`
,UNNEST (hits) AS hits
现在是3月14日,所以日期条件很好


我猜这是因为重复的字段,它显示的会话数量过多。有人能帮我解答语法问题吗?

不需要“最新”。这将起到监督作用:

#standardsql
SELECT 
count(distinct fullvisitorid)

,SUM(totals.visits) AS Sessions
FROM `ga-export-1111.0123456789.ga_sessions_2017*`

您的standardSQL查询有额外的聚合“case when hits.isInteraction=TRUE然后visitId else null end”,这对于legacySQL来说是不存在的。你想数什么?@Mosha,哦,别理它(我忘了取下它,现在就可以了)。这个问题是关于SUM(totals.visions)作为会话的。我之所以问这个问题,是因为这是一个迫使你平抑点击的条款,而这反过来又增加了计数。