test query for aggregation