how to calculate aggregates - Search