BigQuery过度计算事务

时间:2018-05-11 21:57:09

标签: google-bigquery

我正在尝试获取指标(会话,用户,新用户,入口,退回)以及特定来源,广告类型和自定义维度的交易。返回的会话似乎是正确的,但事务是重复的。我不确定如何在命中级别将自定义维度与会话级别的指标混合。

任何想法如何更改查询,以便我不重复值?

<img height="200px" width="200px>

1 个答案:

答案 0 :(得分:2)

下面是BigQuery Standard SQL

   
#StandardSQL
SELECT
  trafficSource.source AS source,
  trafficSource.adContent AS adContent,
  (
    SELECT ANY_VALUE(hcd.value) 
    FROM UNNEST(hits) AS hit,
      UNNEST(hit.customdimensions) AS hcd
    WHERE hcd.index = 10
  ) Destination,
  COUNT(DISTINCT CONCAT(fullVisitorId, CAST(visitStartTime AS STRING) )) Sessions,
  SUM(totals.transactions) transactions
FROM `cc-bigquery-venture.534939.ga_sessions_*`
WHERE _TABLE_SUFFIX BETWEEN '20170101' AND '20170131'
GROUP BY source, adContent, Destination
HAVING Destination IS NOT NULL
AND Destination !=''
AND source = 'dfa' AND adContent = 'vacationcore'
ORDER BY Destination ASC