聚合不能出现在 ON 子句中,除非该子句位于 HAVING 子句或选择列表所包含的子查询中,并且所聚合的列是外部引用。
Click to search this error in Google
English version
An aggregate cannot appear in an ON clause unless it is in a subquery contained in a HAVING clause or select list, and the column being aggregated is an outer reference.