Tested in: 14610 & 14301
The following queries will return the IDs and counts of requests created within a given time frame and completed (Resolved, Closed, Cancelled) within the same time frame.
QUERY FOR INCIDENT REQUESTS:
SELECT STRING_AGG(wo.WORKORDERID :: TEXT, ',') AS "Aging incident ID's", COUNT(wo.WORKORDERID) AS "Aging incident count" FROM WorkOrder wo INNER JOIN WorkOrderStates wos ON wo.WORKORDERID = wos.WORKORDERID INNER JOIN StatusDefinition sd ON wos.STATUSID = sd.STATUSID WHERE wo.IS_CATALOG_TEMPLATE = 'false' AND sd.ISPENDING = 'false' AND TO_TIMESTAMP(wo.CREATEDTIME / 1000.0) >= ('2024-02-01 00:01' :: TIMESTAMP) AND TO_TIMESTAMP(wo.CREATEDTIME / 1000.0) <= ('2024-02-20 00:01' :: TIMESTAMP)
QUERY FOR SERVICE REQUESTS:
SELECT STRING_AGG(wo.WORKORDERID :: TEXT, ',') AS "Aging Service Request ID's", COUNT(wo.WORKORDERID) AS "Aging Service Request count" FROM WorkOrder wo INNER JOIN WorkOrderStates wos ON wo.WORKORDERID = wos.WORKORDERID INNER JOIN StatusDefinition sd ON wos.STATUSID = sd.STATUSID WHERE wo.IS_CATALOG_TEMPLATE = 'true' AND sd.ISPENDING = 'false' AND TO_TIMESTAMP(wo.CREATEDTIME / 1000.0) >= ('2024-02-01 00:01' :: TIMESTAMP) AND TO_TIMESTAMP(wo.CREATEDTIME / 1000.0) <= ('2024-02-20 00:01' :: TIMESTAMP)
>> The required timestamp can be selected in the highlighted area. The same highlighted area can be replaced with the following based on the requirement
To retrieve data for the current week: wo.CREATEDTIME >= <from_thisweek> AND wo.CREATEDTIME <= <to_thisweek>
To retrieve data for the current month: wo.CREATEDTIME >= <from_thismonth> AND wo.CREATEDTIME <= <to_thismonth>
>> For Example: