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.
Why define `col_cnt = 0` above when it is not used anywhere else in this function? Why not just make this line `annotation, _ = inner_query.rewrite_cols(annotation, 0)`? Do you anticipate that `col_cnt` may be needed here in the future?

Or if `col_cnt` is really just an internal implementation detail for the recursive `rewrite_cols`, maybe split it into `rewrite_cols` (taking and returning only annotation) and `_rewrite_cols` (with the full API needed for recursion)?