SELECT wo.WORKORDERID “Request ID”,
cd.CATEGORYNAME “Category”,
scd.NAME “Subcategory”,
tia.FIRST_NAME “Assigned Technician”,
ti.FIRST_NAME “Closing Technician” FROM WorkOrder wo
LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID
LEFT JOIN Workorderhistory wh ON wo.WORKORDERID=wh.WORKORDERID
LEFT JOIN SubCategoryDefinition scd ON wos.SUBCATEGORYID=scd.SUBCATEGORYID
LEFT JOIN CategoryDefinition cd ON wos.CATEGORYID=cd.CATEGORYID
LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID
— Join the closing technician details based on Workorder History details
LEFT JOIN SDUser td ON wh.OPERATIONOWNERID=td.USERID
LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID
— Join the assigned technician details based on the Workorder details
LEFT JOIN SDUser tda ON wos.OWNERID=tda.USERID
LEFT JOIN AaaUser tia ON tda.USERID=tia.USER_ID
WHERE wh.OPERATION=’CLOSE’ AND wo.COMPLETEDTIME >= <from_thisweek> AND wo.COMPLETEDTIME <= <to_thisweek>
For different timescales use the following options in the WHERE statement:
- Today – <from_today> – <to_today>
- This week – <from_thisweek> – <to_thisweek>
- Last week – <from_lastweek> – <to_lastweek>
- This month – <from_thismonth> – <to_thismonth>
- Last month – <from_lastmonth> – <to_lastmonth>
- This quarter – <from_thisquarter> – <to_thisquarter>
- Last quarter – <from_lastquarter> – <to_lastquarter>
- Yesterday – <from_yesterday> – <to_yesterday>
The report is currently looking at the COMPLETEDTIME but this can be changed to CREATEDTIME if you want to work with ticket creation date instead.
Hope it works for you.
Enjoy!