Query to show both requests and task worklog time spent together ( MSSQL )

Query to show both requests and task worklog time spent together ( MSSQL )

Tested in MSSQL build (14306)

Timespent for both tasks and requests

select wo.workorderid "Request ID",
aau.FIRST_NAME "Requester",
cast((((sum(ct.timespent))/1000)/3600) as varchar(20)) +'Hrs '+cast(((((sum(ct.timespent))/1000)/60)) % 60 as varchar(20))+'Mins '+ cast((((sum(ct.timespent))%1000)%60) as varchar(20))+ 'Secs' "Time Spent" from chargestable ct
LEFT JOIN WorkOrderToCharge wotoc ON ct.CHARGEID=wotoc.CHARGEID 
LEFT JOIN WorkOrder wo ON wotoc.WORKORDERID=wo.WORKORDERID
LEFT JOIN SDUser rcti ON ct.TECHNICIANID=rcti.USERID 
LEFT JOIN AaaUser rctd ON rcti.USERID=rctd.USER_ID
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID 
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
group by wo.workorderid,aau.first_name

Timespent on worklogs under tasks

select wo.workorderid "Request ID", 
aau.FIRST_NAME "Requester", 
cast((((sum(ct.timespent))/1000)/3600) as varchar(20)) +'Hrs '+cast(((((sum(ct.timespent))/1000)/60)) % 60 as varchar(20))+'Mins '+ cast((((sum(ct.timespent))%1000)%60) as varchar(20))+ 'Secs' "Time Spent" from WorkOrder wo
LEFT JOIN workordertotaskdetails wotot ON wotot.workorderid=wo.workorderid
LEFT JOIN taskdetails tdet ON wotot.taskid=tdet.taskid
LEFT JOIN tasktocharge ttoch ON ttoch.taskid=tdet.taskid
LEFT JOIN chargestable ct ON ttoch.chargeid=ct.chargeid
LEFT JOIN SDUser rcti ON ct.TECHNICIANID=rcti.USERID 
LEFT JOIN AaaUser rctd ON rcti.USERID=rctd.USER_ID
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID 
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
group by wo.workorderid,aau.first_name

Timespent on worklogs under requests

select wo.workorderid "Request ID", 
aau.FIRST_NAME "Requester", 
cast((((sum(ct.timespent))/1000)/3600) as varchar(20)) +'Hrs '+cast(((((sum(ct.timespent))/1000)/60)) % 60 as varchar(20))+'Mins '+ cast((((sum(ct.timespent))%1000)%60) as varchar(20))+ 'Secs' "Time Spent" from WorkOrder wo
LEFT JOIN workordertocharge wotoc ON wotoc.workorderid=wo.workorderid
LEFT JOIN chargestable ct ON wotoc.chargeid=ct.chargeid
LEFT JOIN SDUser rcti ON ct.TECHNICIANID=rcti.USERID 
LEFT JOIN AaaUser rctd ON rcti.USERID=rctd.USER_ID
LEFT JOIN SDUser sdu ON wo.REQUESTERID=sdu.USERID 
LEFT JOIN AaaUser aau ON sdu.USERID=aau.USER_ID
group by wo.workorderid,aau.first_name







                  New to ADSelfService Plus?

                    • Related Articles

                    • Query to show Last added worklog of a ticket ( MSSQL )

                      Tested in build MSSQL (14306) MSSQL: SELECT wo.WORKORDERID AS "Ticket Number", pd.PRIORITYNAME AS "Priority", cd.CATEGORYNAME AS "Category", qd.QUEUENAME AS "Group", ti.FIRST_NAME AS "Technician", aau.FIRST_NAME AS "Requester", Wo.title "Subject", ...
                    • Query to show both task comments and worklog comments ( MSSQL )

                      Tested in MSSQL build (14306) SELECT "taskdet"."TASKID" AS "Task ID", "taskdet"."TASKID" AS "Task ID", "wotask"."WORKORDERID" AS "RequestID", cd.CATEGORYNAME AS "Request Category", "taskgroup"."QUEUENAME" AS "Group", "taskowner"."FIRST_NAME" AS ...
                    • Query to show tickets that shows total time spent of the ticket more than x hours (MSSQL)

                      Tested in MSSQL build (14306) Query to show tickets that shows total time spent of the ticket more than 8 hours: select ad.org_name "Account", sdo.name "Site", wo.workorderid "Request ID", au.first_name "Assigned Technician", ...
                    • Complete worklog report -MSSQL

                      Query: SELECT aau.FIRST_NAME AS "Requester", max(wo.WORKORDERID) AS "Request ID", rtdef.NAME AS "Request request type", wo.TITLE AS "Subject", wo.description , std.STATUSNAME AS "Request Status", ti.FIRST_NAME AS "Assigned Technician", ...
                    • Query to get total worklog time spent on a request. (PGSQL)

                      Tested in build PGSQL (14300) Scenario: Request1 worklog1-Total time taken to resolve=1 hr 20 mins. worklog2- Total time taken to resolve=1hr 10mins. While generating a report the total time taken to resolve for request1 should be 2 hrs 30mins. ...