Stop AggregateMapper from throwing an error for valid column reference

Previously the AggregateMapper would have issues when a subquery references an outer aggregate but doesn't have an aggregate of it's own. This rearranges some code to first find outer references, then find aggregates within a subquery. 

Conveniently this also fixes a runtime error that occurred under similar circumstances.