【发布时间】:2019-11-26 00:11:27
【问题描述】:
当我尝试运行以下查询时,我发现 Google 分析和 BQ 数据之间存在 15% 的数据差异:
SELECT
SUM(Sessions) AS Sessions
FROM (
SELECT
PARSE_DATE("%Y%m%d",
date) AS DATE,
COUNT(DISTINCT CONCAT(fullVisitorId,"-",CAST(visitStartTime AS STRING))) AS Sessions,
(COUNT(DISTINCT
CASE
WHEN totals.bounces = 1 THEN CONCAT(fullVisitorId, CAST(visitStartTime AS STRING))
ELSE NULL
END ) / COUNT(DISTINCT CONCAT(fullVisitorId, CAST(visitStartTime AS STRING))))*100 AS Bounce_Rate,
COUNT(DISTINCT hits.transaction.transactionId) AS Transactions,
SUM(hits.transaction.transactionRevenue)/1000000 AS Revenue,
SUM(p.productRevenue)/1000000 AS Product_Revenue,
(COUNT(DISTINCT hits.transaction.transactionId) / COUNT(DISTINCT CONCAT(CAST(fullVisitorId AS STRING), CAST(visitStartTime AS STRING))))*100 AS Ecommerce_Conversion_Rate,
(SUM(hits.transaction.transactionRevenue)/1000000)/COUNT(DISTINCT hits.transaction.transactionId) AS Avg_Order_Value,
SUM(hits.item.itemQuantity) / COUNT(hits.transaction.transactionId) AS Avg_Quantity,
device.deviceCategory AS DeviceCategory,
channelGrouping AS DefaultChannelGrouping,
CONCAT(trafficSource.source," / ",trafficSource.medium) AS Source_Medium
FROM
`[Project_ID].[Dataset].ga_sessions_2019*`,
UNNEST(hits) AS hits,
UNNEST(hits.product) AS p
GROUP BY
DATE,
DeviceCategory,
DefaultChannelGrouping,
Source_Medium )
WHERE
DATE BETWEEN "2019-11-17"
AND "2019-11-23"
但是当我摆脱UNNEST(hits.product) AS p 时,我得到的差异程度较低。我想知道如何将UNNEST hits 和hits.product 数据放在一起
【问题讨论】: