add query.max, query.min, and query.count functions