Resolved time Query

Resolved time Query

Database : MYSQL

Execute the below query under Report tab--> New Query Report

SELECT wo.WORKORDERID "Request ID",cd.CATEGORYNAME "Category",scd.NAME "Subcategory",icd.NAME "Item",wo.TITLE "Subject",cri.FIRST_NAME "Created By",ti.FIRST_NAME "Technician",serdef.NAME "Service Category",pd.PRIORITYNAME "Priority",sinfo.WORKSTATIONNAME "Workstation",std.STATUSNAME "Request Status",longtodate(wo.CREATEDTIME) "Created Time",longtodate(wo.COMPLETEDTIME) "Completed Time",
(select from_unixtime(woh.operationtime/1000) from workorderhistory woh where woh.workorderid=wo.workorderid and woh.operation='RESOLVED' and woh.historyid = (select max(historyid) from workorderhistory woh1 where woh1.workorderid=wo.workorderid and woh1.operation='RESOLVED')) 'Resolved Time' FROM WorkOrder wo LEFT JOIN SDUser crd ON wo.CREATEDBYID=crd.USERID LEFT JOIN AaaUser cri ON crd.USERID=cri.USER_ID LEFT JOIN ServiceDefinition serdef ON wo.SERVICEID=serdef.SERVICEID LEFT JOIN SystemInfo sinfo ON wo.WORKSTATIONID=sinfo.WORKSTATIONID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID LEFT JOIN SubCategoryDefinition scd ON wos.SUBCATEGORYID=scd.SUBCATEGORYID LEFT JOIN ItemDefinition icd ON wos.ITEMID=icd.ITEMID LEFT JOIN SDUser td ON wos.OWNERID=td.USERID LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID LEFT JOIN PriorityDefinition pd ON wos.PRIORITYID=pd.PRIORITYID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID 
WHERE  (from_unixtime(wo.createdtime/1000) between '2011-09-20 00:00:00' and '2013-09-20 23:59:59')  AND wo.ISPARENT=1

Note : Change the highlighted from and to dates to provide a date range in the query

Krishna Bharat


                New to ADSelfService Plus?