我正在使用BigQuery中的GoogleAnalytics数据。我想输出2列:特定事件操作(点击)和自定义维度(基于会话)。所有这些,使用标准SQL。我不知道该怎么做。文档编制也无济于事。请帮我。这是我正在尝试的:
SELECT
(SELECT MAX(IF(index=80, value, NULL)) FROM UNNEST(customDimensions)) AS is_app,
(SELECT hits.eventInfo.eventAction) AS ea
FROM
`table-big-query.105229861.ga_sessions_201711*`, UNNEST(hits) hits
WHERE
totals.visits = 1
AND _TABLE_SUFFIX BETWEEN '21' and '21'
AND EXISTS(SELECT 1 FROM UNNEST(hits) hits
WHERE hits.eventInfo.eventCategory = 'SomeEventCategory'
)
尝试提供不属于原始表架构的表和子表名称。总是告诉您要引用的表-交叉联接时,基本上是在添加新列(在此是h.*
-展平)-但旧列(hits.*
-嵌套)仍然存在。我将其命名为ga_sessions_ *,t
并用它来引用交叉联接和customDimension。
另外:您不再需要使用MAX()作为customDimensions的旧版SQL技巧。现在这是一个简单的子查询:)
尝试:
SELECT
(SELECT value FROM t.customDimensions where index=80) AS is_app, -- use h.customDimensions if it is hit-scope
eventInfo.eventAction AS ea
FROM
`projectid.dataset.ga_sessions_201711*` t, t.hits h
WHERE
totals.visits = 1
AND _TABLE_SUFFIX BETWEEN '21' and '21'
AND h.eventInfo.eventCategory is not null
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句