Cannot have aggregate function in JOIN operation <operation>. (Error 3099)

You cannot use an aggregate function in the JOIN operation of an SQL statement.