假设以下BQ查询:
SELECT * FROM(SELECT CONCAT(CAST(fullVisitorId AS String),CAST(visitId AS STRING))AS CustVisitId,hits.hitnumber AS HitNr,hits.transaction.transactionRevenue / …
以下是BigQuery Standard SQL
#standardSQL SELECT *, 1 + (COUNT(Rev) OVER(PARTITION BY CustVisitId ORDER BY HitNr ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING)) `New` FROM ( SELECT CONCAT(CAST(fullVisitorId AS STRING), CAST(visitId AS STRING)) AS CustVisitId, hits.hitnumber AS HitNr, hits.transaction.transactionRevenue/1000000 AS Rev FROM `[projectid].[dataset].ga_sessions_*` AS t, t.hits AS hits WHERE _TABLE_SUFFIX BETWEEN '20190120' AND '20190120' ORDER BY HitNr) WHERE CustVisitId = '49889154628941922861547956449'
如您所见,我保持您的查询不变,只添加了一行 New
New