我在BigQuery上相当称职,但这让我感到困惑。我从会话表和实时表中提取用户,交易和收入。前几天我得到的结果与我在Google Analytics(分析)中获得的结果是准确的,但是当日的收入和交易却被夸大了(用户是准确的)。
这感觉像是一个嵌套问题,但是为什么会影响当天而不是前几天?
感谢您提供的任何建议。
WITH
ga_tables AS (
SELECT
CAST(CONCAT(SUBSTR(date,1,4),'-',SUBSTR(date,5,2),'-',SUBSTR(date,7,2)) AS DATE) AS Date,
(
SELECT
MAX(IF(index = 27,
value,
''))
FROM
UNNEST(customDimensions)) AS PracticeName,
COUNT(DISTINCT fullVisitorId) AS users,
SUM(totals.transactions) AS transactions,
SUM(totals.totalTransactionRevenue)/1000000 AS revenue
FROM
`big-query-project-34643.162968675.ga_sessions_*` ga
WHERE
_TABLE_SUFFIX BETWEEN FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 100 DAY))
AND FORMAT_DATE('%Y%m%d', DATE_SUB(CURRENT_DATE(), INTERVAL 0 DAY))
GROUP BY
date,
PracticeName
UNION ALL
SELECT
CAST(CONCAT(SUBSTR(date,1,4),'-',SUBSTR(date,5,2),'-',SUBSTR(date,7,2)) AS DATE) AS Date,
(
SELECT
MAX(IF(index = 27,
value,
''))
FROM
UNNEST(customDimensions)) AS PracticeName,
COUNT(DISTINCT fullVisitorId) AS users,
SUM(totals.transactions) AS transactions,
SUM(totals.totalTransactionRevenue)/1000000 AS revenue
FROM
`big-query-project-34643.162968675.ga_exportKey_view_2`
GROUP BY
date,
PracticeName)
SELECT
Date AS Date,
SUM(users) AS users,
SUM(transactions) AS transactions,
SUM(revenue) AS revenue
FROM
ga_tables
WHERE
LOWER(PracticeName) NOT LIKE '%demo%'
AND LOWER(PracticeName) NOT LIKE 'vip'
GROUP BY
Date
ORDER BY
date DESC```