sort the results in aggregate API by count

amaradiswamy
Kilo Sage

Hi All,

I have one aggregate API which shows the count of incidents created groupby CI. My requirement is to sort result we got from the rest message based on the count. i.e, CI with maximum count should come first.

Is there anyway to do this?

Thanks and regards

Swamy

5 REPLIES 5

dvp
Mega Sage
Mega Sage

Yes you can use



gr.orderByAggregate('count');


as far as I know order by aggregate is not available of an encoded query..


the other way you can do sort after data is received


Set the value of   sysparm to COUNT^DESC or encoded: COUNT%5EDESC



Check the documentation for details:


Aggregate API - GET /now/stats/{tableName}