BIGQUERY 错误 --> SELECT 列表表达式引用列 FY,该列既未在 [4:20] 分组也未聚合

BIGQUERY Error --> SELECT list expression references column FY which is neither grouped nor aggregated at [4:20]

我遇到这个错误"SELECT list expression references column FY which is neither grouped nor aggregated at [4:20]"这是SQL句子:

SELECT '00-ActualTotalRevenues' as type,code, previous_code,
     name as master1,'' as master2,'' as master3,'' as master4,'' as master5,
case when FY < 2018 then sum(January+February+March+April+May+June+July+August+September+October+November+December) else 0 end as detail,
     case when FY = 2018 then sum(January) else 0 end as detail1,
     case when FY = 2018 then sum(February) else 0 end as detail2,
     case when FY = 2018 then sum(March) else 0 end as detail3,
     case when FY = 2018 then sum(April) else 0 end as detail4,
     case when FY = 2018 then sum(May) else 0 end as detail5,
     case when FY = 2018 then sum(June) else 0 end as detail6,
     case when FY = 2018 then sum(July) else 0 end as detail7,
     case when FY = 2018 then sum(August) else 0 end as detail8,
     case when FY = 2018 then sum(September) else 0 end as detail9,
     case when FY = 2018 then sum(October) else 0 end as detail10,
     case when FY = 2018 then sum(November) else 0 end as detail11,
     case when FY = 2018 then sum(December) else 0 end as detail12 
FROM `basetis-etl-bigquery.services.results_actual_revenues_complete` where FY <= 2018
group by 1,2,3,4,5,6,7,8

以下查询运行没有问题:

SELECT '00-ActualTotalRevenues' as type,code, previous_code,
     name as master1,'' as master2,'' as master3,'' as master4,'' as master5,
sum(January) as detail1,
sum(February) as detail2,
sum(March) as detail3,
sum(April) as detail4,
sum(May) as detail5,
sum(June) as detail6,
sum(July) as detail7,
sum(August) as detail8,
sum(September) as detail9,
sum(October) as detail10,
sum(November) as detail11,
sum(December) as detail12 
FROM `basetis-etl-bigquery.services.results_actual_revenues_complete` where FY <= 2018
group by 1,2,3,4,5,6,7,8

提前感谢您的支持。

亲切的问候

改用下面的内容

#standardSQL
SELECT '00-ActualTotalRevenues' AS type, code, previous_code,
  name AS master1,'' AS master2,'' AS master3,'' AS master4,'' AS master5,
  SUM(IF(FY < 2018, January+February+March+April+May+June+July+August+September+October+November+December, 0))AS detail,
  SUM(IF(FY = 2018, January, 0)) AS detail1,
  SUM(IF(FY = 2018, February, 0)) AS detail2,
  SUM(IF(FY = 2018, March, 0)) AS detail3,
  SUM(IF(FY = 2018, April, 0)) AS detail4,
  SUM(IF(FY = 2018, May, 0)) AS detail5,
  SUM(IF(FY = 2018, June, 0)) AS detail6,
  SUM(IF(FY = 2018, July, 0)) AS detail7,
  SUM(IF(FY = 2018, August, 0)) AS detail8,
  SUM(IF(FY = 2018, September, 0)) AS detail9,
  SUM(IF(FY = 2018, October, 0)) AS detail10,
  SUM(IF(FY = 2018, November, 0)) AS detail11,
  SUM(IF(FY = 2018, December, 0)) AS detail12 
FROM `basetis-etl-bigquery.services.results_actual_revenues_complete` WHERE FY <= 2018
GROUP BY 1,2,3,4,5,6,7,8