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.
@carljm a `Ref` is only returned if it exists within the `query.annotations` property, which guarantees that it'll be added to the select list. `sql.query.resolve_ref()` is responsible for returning a `Ref` or `Col`. Still, a "see self.resolve_ref" may be useful within the comment.