Query to show technician hop count

Query to show technician hop count

MSSQL:

SELECT wo.WORKORDERID "Request ID", LONGTODATE(wo.CREATEDTIME) AS "Created Time", qd.QUEUENAME "Current Group",aau.FIRST_NAME AS "Requester",  ti.FIRST_NAME "Technician", ad.ORG_NAME AS "Account", ti1.FIRST_NAME "From technician",
ti2.FIRST_NAME "To technician", count(wti.ASSESSMENTID) "Ticket Hop Count"
 FROM WorkOrder wo LEFT JOIN WorkOrderStates wos ON wo.WORKORDERID=wos.WORKORDERID 
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
LEFT JOIN SDUser td ON wos.OWNERID=td.USERID 
LEFT JOIN AaaUser ti ON td.USERID=ti.USER_ID 
left join wo_assessment woa on wo.workorderid=woa.workorderid
inner join WO_TECH_INFO wti on woa.assessmentid=wti.assessmentid
LEFT JOIN WorkOrder_Queue woq ON wo.WORKORDERID=woq.WORKORDERID 
LEFT JOIN QueueDefinition qd ON woq.QUEUEID=qd.QUEUEID
LEFT JOIN AaaUser ti1 ON wti.technicianid=ti1.USER_ID
LEFT JOIN AaaUser ti2 ON wti.nexttechnicianid=ti2.USER_ID 
LEFT JOIN AccountSiteMapping asm ON wo.siteid=asm.siteid
LEFT JOIN AccountDefinition ad ON asm.accountid=ad.org_id
WHERE (wo.ISPARENT='1') AND ti2.FIRST_NAME is NOT NULL GROUP BY wo.CREATEDTIME, wo.WORKORDERID, ti.FIRST_NAME ,qd.QUEUENAME , ti1.FIRST_NAME, ti2.FIRST_NAME, ad.ORG_NAME, aau.FIRST_NAME ORDER BY 1, 2