dell view (srms,click,fdl)
USE [DellPII]
GO
/****** Object: View [dbo].[vw_UCAREPII_TXNS] Script Date: 3/29/2022 10:35:19 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE VIEW [dbo].[vw_UCAREPII_TXNS] As
SELECT
DISTINCT IT.Incident_Number,
'1' as clientid,
IA.Completion_DateTime,
IT.Datasourceid,
'SRMS' AS Datasourcename
FROM ODS.DBO.incident_srms_specific IT WITH (NOLOCK)
LEFT OUTER JOIN ODS.DBO.incident_srms_attention IA WITH (NOLOCK)
ON ( IT.incident_number =IA.incident_number )
WHERE IT.DATASOURCEID=42 AND IA.attention_completion_code='C' AND
IT.National_Account_ID in
(select pii.ClientID from PIIClientChild pii WITH (NOLOCK) where pii.ClientParentID=1)
and IA.Completion_DateTime<=DATEADD(d,-90, getdate())
UNION ALL
SELECT
DISTINCT W.NUMBER AS Incident_number,
'2' as clientid,
W.work_end AS CompletionDate,
'77' as Datasourceid,
'FSM' AS Datasourcename
FROM ODS_SN_FSM.DBO.wm_task W
WHERE
W.U_SRMS =0
AND W.dv_state IN ('Closed Complete')
AND W.work_end<=DATEADD(d,-90, getdate())
--(select pii.ClientID from PIIClientChild pii WITH (NOLOCK) where pii.ClientParentID=2)
UNION ALL
SELECT
DISTINCT WT.CallID AS Incident_number,
'3' as clientid,
WT.CompletionDate,
Null as Datasourceid,
'CLICK' AS Datasourcename
FROM UNNCLICKDBT.DBO.w6tasks WT WITH (NOLOCK)
WHERE WT.GlobalAccountID in
(select pii.ClientID from PIIClientChild pii WITH (NOLOCK) where pii.ClientParentID=3)
and WT.CompletionDate<=DATEADD(d,-90, getdate())
GO
Comments
Post a Comment