sort the results in aggregate API by count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 03:24 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 03:36 AM
Yes you can use
gr.orderByAggregate('count');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 03:45 AM
Hi,
Thanks for the reply !!
But, how can i exclude this in below API?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 05:57 PM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2017 07:49 PM
Set the value of sysparm to COUNT^DESC or encoded: COUNT%5EDESC
Check the documentation for details:
Aggregate API - GET /now/stats/{tableName}