Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/webpack/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google bigquery 使用where语句和展平自定义维度_Google Bigquery - Fatal编程技术网

Google bigquery 使用where语句和展平自定义维度

Google bigquery 使用where语句和展平自定义维度,google-bigquery,Google Bigquery,我构建了以下查询: SELECT MAX(IF (hits.customDimensions.index = 10, hits.customDimensions.value, NULL)) WITHIN RECORD AS postId, DATE(MAX(IF (hits.customDimensions.index = 4, hits.customDimensions.value, NULL))) WITHIN RECORD AS Datepublished, MAX(IF (h

我构建了以下查询:

SELECT
  MAX(IF (hits.customDimensions.index = 10, hits.customDimensions.value, NULL)) WITHIN RECORD AS postId,
  DATE(MAX(IF (hits.customDimensions.index = 4, hits.customDimensions.value, NULL))) WITHIN RECORD AS Datepublished,
  MAX(IF (hits.customDimensions.index = 1, hits.customDimensions.value, NULL)) WITHIN RECORD AS Country,
  MAX(IF (hits.customDimensions.index = 7, hits.customDimensions.value, NULL)) WITHIN RECORD AS Author,
FROM
  (TABLE_DATE_RANGE([storied-toolbox-145015:102152044.ga_sessions_], DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'), DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY')))
但是,我希望能够使用基于自定义维度之一的where语句。类似这样的
where Country='fr'
。我尝试过各种解决方案,但我总是遇到Over子句错误或scope错误

因为我想在GoogleDataStudio中使用这个查询,所以我需要使用SQL legacy来构建它

谢谢

。。。我希望能够基于一个自定义维度使用where语句

下面假设您的查询按照您的预期工作,因此它只解决按国家“筛选”的问题,这基本上就是问题所在

SELECT
  MAX(IF (hits.customDimensions.index = 10, hits.customDimensions.value, NULL)) WITHIN RECORD AS postId,
  DATE(MAX(IF (hits.customDimensions.index = 4, hits.customDimensions.value, NULL))) WITHIN RECORD AS Datepublished,
  MAX(IF (hits.customDimensions.index = 1, hits.customDimensions.value, NULL)) WITHIN RECORD AS Country,
  MAX(IF (hits.customDimensions.index = 7, hits.customDimensions.value, NULL)) WITHIN RECORD AS Author,
FROM
  (TABLE_DATE_RANGE([storied-toolbox-145015:102152044.ga_sessions_], DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY'), DATE_ADD(CURRENT_TIMESTAMP(), -1, 'DAY')))
HAVING Country = 'fr'  
正如您所看到的,“诀窍”在于在此处使用
have
,而不是
WHERE