Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- insert into [SMI.Monitoring].[dbo].general_detail
- SELECT T.ID, T.Process_ID, T.Activity_ID, T.Transaction_ID, T.Outcome, T.Remark, T.Actioner,
- T.ActionDate, T.Orig_Dest, T.Task_Received_Date, T.Process_Name, T.Employee_Name,
- T.Activity_Name, T.Action_Name,
- case
- when PrevDate is null then 0
- else DATEDIFF("n", PrevDate,ActionDate)
- end as time_diff,
- case
- when (convert (bigint, (DATEDIFF("n", PrevDate,ActionDate))) > T.sla) then 1
- else 0
- end as is_meet_sla,
- case
- when(convert (bigint, (DATEDIFF("n", PrevDate,ActionDate))) > T.threshold) then 2
- when(convert (bigint, (DATEDIFF("n", PrevDate,ActionDate))) = T.threshold) then 1
- when(convert (bigint, (DATEDIFF("n", PrevDate,ActionDate))) < T.threshold) then 0
- end as is_meet_threshold,
- T.is_finish
- FROM ( SELECT *,
- ( SELECT MAX(ActionDate)
- FROM [SMI.Monitoring].[dbo].[temp_general_detail] T2
- WHERE T2.Transaction_ID = T1.Transaction_ID
- AND T2.ActionDate < T1.ActionDate
- ) AS PrevDate,
- ( select sla from [SMI.Monitoring].dbo.sla_param where sla_param.sla_desc = Activity_Name AND sla_param.jenis_dokumen = 'Nota Dinas Masuk' ) as sla,
- ( select threshold from [SMI.Monitoring].dbo.sla_param where sla_param.sla_desc = Activity_Name AND sla_param.jenis_dokumen = 'Nota Dinas Masuk' ) as threshold,
- ( select is_last_state from [SMI.Monitoring].dbo.sla_param where sla_param.sla_desc = Activity_Name AND sla_param.jenis_dokumen = 'Nota Dinas Masuk' ) as is_finish
- FROM [SMI.Monitoring].[dbo].[temp_general_detail] T1
- WHERE Process_ID in (7)
- ) AS T
- WHERE not exists ( select ID from [SMI.Monitoring].[dbo].general_detail where ID = T.ID)
- order by Transaction_ID, ActionDate
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement