- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 10:36 AM
Hi All,
Please check the attached screenshot.
In Script1, I am using GlideAggregate groupBy function and then doing the MAX aggregation, its giving me the expected output (maximum value from the set of records which were in that group).
In Script2, I am directly aggregating the MAX, its not giving the desired output. If there is no groupBy then, it should consider all the records of the table and give the maximum value. But its giving the minimum value. Can someone please explain me this?
Why is MAX aggregation not working without the groupBy?
Documentation link:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2023 12:19 AM
Hi,
You need to make sure it should not be grouped.
Please use below script for the desired result.
var t=new GlideAggregate('incident')
t.addAggregate('max','sys_mod_count');
t.setGroup(false);
t.query();
if(t.next())
gs.info(t.getAggregate('max','sys_mod_count'))
Thanks and Regards,
Saurabh Gupta
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2023 12:19 AM
Hi,
You need to make sure it should not be grouped.
Please use below script for the desired result.
var t=new GlideAggregate('incident')
t.addAggregate('max','sys_mod_count');
t.setGroup(false);
t.query();
if(t.next())
gs.info(t.getAggregate('max','sys_mod_count'))
Thanks and Regards,
Saurabh Gupta