handle count only for aggregate queries