Query to track technician activity on tickets (MSSQL & PGSQL)

Query to track technician activity on tickets (MSSQL & PGSQL)

Tested in build PGSQL (14300) and MSSQL (14306)

Use case: This query will help you find what are all activities that the technicians have done on requests other than the assigned ones

SELECT au.first_name "Technician" ,wo.WORKORDERID "Request ID",aau.FIRST_NAME "Requester",wo.TITLE "Subject",std.STATUSNAME "Request Status",Longtodate(wo.CREATEDTIME) "Created Time",Longtodate(wo.COMPLETEDTIME) "Completed Time",
ti.FIRST_NAME "Assigned Technician",au.first_name "Operation performed Technician",
(woh.Operation) "Operation",
wohd.columnname "Column Name",
LONGTODATE(OPERATIONTIME) "OPERATIONTIME"
  FROM WorkOrder wo 
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID 
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID LEFT JOIN SDUser td ON wos.OWNERID=td.USERID LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID LEFT JOIN StatusDefinition std ON wos.STATUSID=std.STATUSID  left join workorderhistory woh on wo.workorderid=woh.workorderid LEFT JOIN WorkOrderHistoryDiff wohd ON woh.HISTORYID = wohd.HISTORYID  left join aaauser au on woh.operationownerid=au.user_id where  (wo.ISPARENT='1') AND au.first_name='administrator'  AND woh.OPERATIONTIME>=<from_thismonth>and woh.OPERATIONTIME<=<to_thismonth>  order by 1

NOTE:
1. Technician name is highlighted in the query, you can replace with the exact name of the technician to pull this report.

2. Date filter highlighted in the query can be modified and below parameters can be used instead.

It is not advised to show more than a month's data and data for only one technician at the same time as it impacts application performance since it involves request history table.

How to compare date column with auto filled date templates?
  1. Here is the example for getting this week data - CREATEDTIME >= <from_thisweek> AND CREATEDTIME <= <to_thisweek>
    • <from_thisweek> - Starting date of this week
    • <to_thisweek> - Ending date of this week
  2. Available Date Templates
    • 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>

                  New to ADSelfService Plus?