fix handling of range parameters in COUNT, fdo#72999

Change-Id: I352c6b415f0990890702fa21175c196d7f4b12ee
add test case for fdo#72999

Change-Id: I256e0cb228edb85b402e6645fd40f24b7ccf234a