fix handling of range parameters in COUNT, fdo#72999

Change-Id: I352c6b415f0990890702fa21175c196d7f4b12ee