An aggregate cannot appear in an ON clause unless it is in a subquery contained in a HAVING clause or select list, and the ...