彙總不得出現於 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.