Query to find number of requests assigned to a technician. (MSSQL & PGSQL)

Query to find number of requests assigned to a technician. (MSSQL & PGSQL)


Tested in builds PGSQL (14300) or MSSQL (14306)
This query is used to show how many tickets are assigned to a particular technician within a given timeframe (even if these tickets end up being re-assigned again)

PGSQL:

SELECT 
aau.FIRST_NAME AS "Technician Name",
COUNT(Distinct wo.WORKORDERID) AS "Ticket Count"
FROM WORKORDER wo
LEFT JOIN WO_ASSESSMENT wa ON wo.WORKORDERID=wa.WORKORDERID
LEFT JOIN WO_TECH_INFO wti ON wa.ASSESSMENTID=wti.ASSESSMENTID
LEFT JOIN SDUSER sd ON wti.TECHNICIANID=sd.USERID
LEFT JOIN AAAUSER aau ON sd.USERID = aau.USER_ID
WHERE wa.EXECUTEDTIME >= <from_thisweek> AND wa.EXECUTEDTIME <= <to_thisweek> AND (wti.TECHNICIANID is not null) AND (wo.ISPARENT='1')
GROUP BY "Technician Name"


MSSQL:

SELECT 
aau.FIRST_NAME AS "Technician Name",
COUNT(Distinct wo.WORKORDERID) AS "Ticket Count"
FROM WORKORDER wo
LEFT JOIN WO_ASSESSMENT wa ON wo.WORKORDERID=wa.WORKORDERID
LEFT JOIN WO_TECH_INFO wti ON wa.ASSESSMENTID=wti.ASSESSMENTID
LEFT JOIN SDUSER sd ON wti.TECHNICIANID=sd.USERID
LEFT JOIN AAAUSER aau ON sd.USERID = aau.USER_ID
WHERE wa.EXECUTEDTIME >= <from_thisweek> AND wa.EXECUTEDTIME <= <to_thisweek> AND (wti.TECHNICIANID is not null) AND (wo.ISPARENT='1')
GROUP BY aau.FIRST_NAME


                  New to ADSelfService Plus?