在 FROM 子句包含被聚合列所在的表的查询中,包含外部引用的被聚合表达式必须包含在选择列表或 HAVING 子句子查询中。
Click to search this error in Google
English version
An aggregated expression containing an outer reference must be contained in either the select list, or a HAVING clause subquery in the query whose FROM clause contains the table with the column being aggregated.