fixed totals for grouping queries