Add query.sum and query.average functions