Query to get the time spent in the “unassigned” status for each request before the request is assigned to a technician.

Query to get the time spent in the “unassigned” status for each request before the request is assigned to a technician.

Time spent column format to DD:HH:MM:SS

SELECT wo.WORKORDERID AS "Request ID", a.first_name as "Changed From",aa.first_name as "Changed To",longtodate(wot.ENDTIME) as "Changed Time",concat(floor(wot.TIMESPENT/(1000*60*60*24)),':',floor(Mod(wot.TIMESPENT, 24*60*60*1000)/(60*60*1000)),':',floor(mod(Mod(wot.TIMESPENT, 24*60*60*1000),(60*60*1000))/(60*1000)),':',floor(Mod(mod(Mod(wot.TIMESPENT, 24*60*60*1000),(60*60*1000)),(60*1000))/1000),'') as "TimeSpent by Previous Technician(min)" FROM WorkOrder wo    LEFT JOIN WO_Assessment woas ON wo.WORKORDERID = woas.WORKORDERID    LEFT JOIN WO_Tech_Info wot ON woas.ASSESSMENTID = wot.ASSESSMENTID    LEFT JOIN AAAUser a ON wot.TECHNICIANID = a.USER_ID    LEFT JOIN AAAUser aa ON wot.NEXTTECHNICIANID = aa.USER_ID WHERE    (       wo.ISPARENT = '1'       and wot.NEXTTECHNICIANID IS Not Null       and wo.createdtime>=<from_thismonth>and wo.createdtime<=<to_thismonth>    ) ORDER BY    1,    woas.ASSESSMENTID asc

                    New to ADSelfService Plus?