Requirement to show top three records from event table based on some field value for unique CI's

Community Alums
Not applicable
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-19-2024 04:42 AM
Dear Community,
I have a requirement to show top three records based on the message value(can be seen in screen-shot) so we need to orderBy message value and for unique Configuration Item(can be seen in screen-shot) so we need to groupBy cmdb_ci, I tried this but not able to get the result. Please find the below Screen-shot and Code for the same:
First try:
var ga = new GlideAggregate('em_event');
ga.addAggregate('COUNT');
ga.orderByDesc('message_key');
ga.groupBy('cmdb_ci');
ga.query();
while(ga.next()) {
gs.print() // here I need to print unique CI name having top message_key value but currently it is not working
}
0 REPLIES 0