Group by and ordering of aggregates