Fixed #23877 -- aggregation's subquery missed target col

Aggregation over subquery produced syntactically incorrect queries in
some cases as Django didn't ensure that source expressions of the
aggregation were present in the subquery.
Where is it taken care of that a `Ref` will already exist in the inner query? Might be nice to have that information here.