Hi,
I have a query where I require to exclude "Hold Status" time b/w open to acknowledge status.
So, support I have ticket '9607' and it is in the Open Status(INIT) and assigned. While selecting open to Hold and hold to open and then open to Acknowledge. It Will only calculate the time of open to Acknowledge and exclude the Hold time. So this will be a loop that how many times the Hold status will come.
And the Hold status will be required to catch from act_log table.
And also require to calculate the Mean of all the tickets time_stamp.
Below is the query which is calculating the time_stamp on each Status its showing on Unix time also require to convert it it Days hrs mins seconds
------------------------------------------------------------------------------------------------------------------
Following is the query:
WITH TIMEDIFF AS
(
SELECT call_req.ref_num , call_req.type type1 , ca_contact.first_name, ca_contact.last_name
,ROW_NUMBER() OVER ( ORDER BY ref_num, time_stamp ) as RowNumber ,
act_log.id , act_log.persid , call_req_id , act_log.analyst, SUBSTRING( action_desc , PATINDEX ( '% assignee from %', action_desc ) + 15 , DATALENGTH( action_desc ) -2 ) team ,
act_log.action_desc , act_log.type , dateadd (S,[time_stamp], '1970-01-01') Activity_Date ,act_log.time_stamp
FROM call_req inner join act_log on call_req.persid = act_log.call_req_id inner join ca_contact on act_Log.analyst = ca_contact.contact_uuid
where ca_contact.contact_type='2307' and call_req.type = 'I'
and act_log.type in ( 'TR' , 'INIT','RE','ST' ) and call_req.ref_num ='9607'
)
select cur.id , cur.type1, cur.Activity_Date, cur.persid , cur.call_req_id ,cur.first_name,cur.last_name, cur.ref_num, replace ( left( cur.team ,CHARINDEX( ' to ' , cur.team) ) , '''', '') TeamName , cur.time_stamp ,
cur.type , ( cur.time_stamp - pre.time_stamp ) Time_Taken from TIMEDIFF cur
LEFT OUTER JOIN TIMEDIFF pre on cur.RowNumber = pre.RowNumber +1
-----------------------------------------------------------------------------
I am including the following:
- Result of the Above query save in txt file but can be open as CSV
- act_log table result w.r.t ref_number 9607
Please let me know if you require more information from my end. 217821-query-resule.txt217795-act-log-9607-updated.txt