Group by query in Service-now!!!!

alok17
Kilo Explorer

Hi,

Any one can reply me how we write this query in Service-now.

SELECT INC_NO, MAX (LAST_MODIFIED_DATE_TIME) FROM TABLE_NAME WHERE ACTIVE = 'true' GROUP BY INCIDENT_NO

Thanks

2 REPLIES 2

gaidem
ServiceNow Employee
ServiceNow Employee

Need more details...

You syntax suggests SQL, which would only apply in a DB view. Where are you trying to provide this logic? Can you provide your business case?


jkhanddh
Tera Contributor

Hi Alok,
The answer you are looking for depends on use case.
1. If you want this to be applied on list view of a table, directly click on filter option available in top left corner and set active as true. Once data is presented then right click on header "INCIDENT_NO" and select option "group by".
2. If you wanna code use Glide Aggregate API's groupBy method to achieve this