Implementing record number reduction by partial aggregation