Special-case logic for aggregations in select queries.