Query to retrieve the aging days details of requests

Query to retrieve the aging days details of requests

Tested in: 14610 (Postgres)

Query:

SELECT wo.WORKORDERID AS "Request ID", req.FIRST_NAME AS "Requester", LONGTODATE(wo.CREATEDTIME) AS "Created Date", LONGTODATE(wo.RESOLVEDTIME) AS "Resolved Date", (FLOOR(wo.TIMESPENTONREQ / (1000 * 60 * 60 * 24))::INT) AS "Ageing Day", (CASE WHEN  wo.IS_CATALOG_TEMPLATE = 'true' THEN 'Service Request' ELSE 'Incident Request' END ) AS "Request Type", qd.QUEUENAME AS "Group", pd.PRIORITYNAME AS "Priority" FROM WorkOrder wo LEFT JOIN AaaUser req ON wo.REQUESTERID =req.USER_ID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID =wos.WORKORDERID LEFT JOIN WorkOrder_Queue wq ON wo.WORKORDERID=wq.WORKORDERID LEFT JOIN QueueDefinition qd ON wq.QUEUEID = qd.QUEUEID LEFT JOIN PriorityDefinition pd ON wos.PRIORITYID = pd.PRIORITYID WHERE wo.WORKORDERID NOT IN (SELECT wo1.WORKORDERID FROM  WorkOrder wo1 LEFT JOIN WorkOrderStates wos1 ON wo1.WORKORDERID = wos1.WORKORDERID LEFT JOIN StatusDefinition std1 ON wos1.STATUSID = std1.STATUSID LEFT JOIN AaaUser tech ON wos1.OWNERID = tech.USER_ID WHERE tech.FIRST_NAME = 'Mr Robot' AND std1.ISPENDING ='false')

Result:


                  New to ADSelfService Plus?