0

简而言之,我有以下 SQL 语句,table其中包含id我需要获取过去一年的网站行为的 s 列表。这些ids 应该匹配customDimensions.value

SELECT fullVisitorId, visitNumber, totals.pageviews, customDimensions.value as client_id
FROM (
SELECT * FROM
  TABLE_DATE_RANGE([xxxxxxx.ga_sessions_],
                    TIMESTAMP('2017-01-01'),
                    TIMESTAMP('2018-01-01'))
                    )
WHERE customDimensions.index = 2 AND customDimensions.value IN (SELECT STRING(id) FROM [table])
GROUP BY 1,2,3,4

我得到错误:

错误:无法加入重复字段 customDimensions.value

4

1 回答 1

1

我看到您仍然使用 BigQuery Legacy SQL,所以下面是旧 sql

假设您的原始查询的其余部分执行您想要的操作 - 它解决了以下错误

错误:无法加入重复字段 customDimensions.value

#legacySQL
SELECT fullVisitorId, visitNumber, totals.pageviews, customDimensions.value AS client_id
FROM FLATTEN((
SELECT * FROM
  TABLE_DATE_RANGE([xxxxxxx.ga_sessions_],
                    TIMESTAMP('2017-01-01'),
                    TIMESTAMP('2018-01-01'))
                    ), customDimensions)
WHERE customDimensions.index = 2 AND customDimensions.value IN (SELECT STRING(id) FROM [table])
GROUP BY 1,2,3,4   
于 2018-04-17T20:12:25.583 回答