侧步骤sql数据类型转换

bttbmeg0  于 2021-07-24  发布在  Java
关注(0)|答案(0)|浏览(229)

我正在查询sql视图,但不断出现以下错误:
将nvarchar值“rejected”转换为int数据类型时转换失败。
我使用的查询如下:

SELECT DISTINCT [event]
FROM V_S_EVENT_TIMESERIES_AP

在中没有称为“拒绝”的值 event 所以我有以下问题:
这个价值从何而来?
为什么要把它转换成int?
如何避开转换以避免错误?
我非常感谢你的帮助。提前多谢了。
[编辑]:
这个 DDL :

CREATE VIEW [dbo].[V_S_EVENT_TIMESERIES_AP] 
AS
    SELECT  
        [contactID], [date], [accntID],
        [event], [hasEmail_FLG],
        [CUST_STAT_CD], [SUPPRESS_EMAIL_FLG], [SUPPRESS_CALL_FLG], 
        [SUPPRESS_MAIL_FLG], [ACTIVE_FLG],
        [WORK_PHONE_NUM],
        [MAIN_PHONE_NUM], [JOB_ROLE], [JOB_FUNCTION],
        [hasPhone_FLG],
        [workPhoneSuperScore], [QCApproved],
        [HQL_ID], [RESP_TYPE_CD], [STATUS_CD], [OptyID],
        [Disposition], [SubDisposition], [AETimezone]
    FROM
        ((SELECT 
              S_CONTACT.ROW_ID AS [contactID], S_CONTACT.CREATED AS [date],
              'ContactCreation' AS [event],
              CASE
                 WHEN S_CONTACT.EMAIL_ADDR IS NOT NULL THEN 1
                 ELSE 0
              END AS [hasEmail_FLG],
              S_CONTACT.CUST_STAT_CD, S_CONTACT.SUPPRESS_EMAIL_FLG, 
              S_CONTACT.SUPPRESS_CALL_FLG, 
              S_CONTACT.SUPPRESS_MAIL_FLG,S_CONTACT.ACTIVE_FLG,
              S_CONTACT2.ACCOUNT_ID AS [accntID], S_CONTACT2.WORK_PHONE_NUM,
              S_CONTACT2.MAIN_PHONE_NUM, S_CONTACT2.JOB_ROLE,
              S_CONTACT2.JOB_FUNCTION,
              CASE
                 WHEN S_CONTACT2.MAIN_PHONE_NUM IS NOT NULL OR 
                      S_CONTACT2.WORK_PHONE_NUM IS NOT NULL 
                    THEN 1
                    ELSE 0
              END AS [hasPhone_FLG],
              CASE
                 WHEN S_CONTACT2.WORK_PHONE_NUM IS NOT NULL AND 
                      S_CONTACT2.WORK_PHONE_NUM != S_CONTACT2.MAIN_PHONE_NUM 
                    THEN 1
                    ELSE 0
              END AS [workPhoneSuperScore], 
              NULL AS [QCApproved], NULL AS [HQL_ID],
              NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD], NULL AS [OptyID],
              NULL AS [Disposition], NULL AS [SubDisposition],
              NULL AS [AETimezone]
          FROM 
              Reporting.dbo.S_CONTACT
          LEFT JOIN 
              AnalyticsDB.dbo.V_S_CONTACT_full AS [S_CONTACT2] ON S_CONTACT.ROW_ID = S_CONTACT2.CONTACT_ID)

          UNION

          (SELECT 
               S_CONTACT2.CONTACT_ID AS [contactID],
               S_CONTACT2.X_LINKEDIN_VERIFIED_DATE AS [date],
               'LinkedInVerification' AS [event],
               NULL AS [hasEmail_FLG],
               NULL AS [CUST_STAT_CD], NULL AS [SUPPRESS_EMAIL_FLG], 
               NULL AS [SUPPRESS_CALL_FLG], 
               NULL AS [SUPPRESS_MAIL_FLG], NULL AS [ACTIVE_FLG],
               S_CONTACT2.ACCOUNT_ID AS [accntID], NULL AS [WORK_PHONE_NUM],
               NULL AS [MAIN_PHONE_NUM], NULL AS [JOB_ROLE], NULL AS [JOB_FUNCTION],
               NULL AS [hasPhone_FLG],
               NULL AS [workPhoneSuperScore], NULL AS [QCApproved],
               NULL AS [HQL_ID], NULL AS [RESP_TYPE_CD], 
               NULL AS [STATUS_CD], NULL AS [OptyID],
               NULL AS [Disposition], NULL AS [SubDisposition],
               NULL AS [AETimezone]
           FROM 
               AnalyticsDB.dbo.V_S_CONTACT_full AS [S_CONTACT2]
           WHERE 
               S_CONTACT2.X_LINKEDIN_VERIFIED_DATE IS NOT NULL)
          UNION
          (SELECT 
               S_CONTACT2.CONTACT_ID AS [contactID],
               S_CONTACT2.X_MRP_VERIFIED_DATE AS [date],
               'MRPVerification' AS [event],
               NULL AS [hasEmail_FLG], NULL AS [CUST_STAT_CD], 
               NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
               NULL AS [SUPPRESS_MAIL_FLG], NULL AS [ACTIVE_FLG],
               S_CONTACT2.ACCOUNT_ID AS [accntID],
               NULL AS [WORK_PHONE_NUM], NULL AS [MAIN_PHONE_NUM],
               NULL AS[JOB_ROLE], NULL AS [JOB_FUNCTION],
               NULL AS [hasPhone_FLG], NULL AS [workPhoneSuperScore],
               NULL AS [QCApproved], NULL AS [HQL_ID],
               NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],
               NULL AS [OptyID], NULL AS [Disposition],
               NULL AS [SubDisposition], NULL AS [AETimezone]
           FROM 
               AnalyticsDB.dbo.V_S_CONTACT_full AS [S_CONTACT2]
           WHERE 
               S_CONTACT2.X_MRP_VERIFIED_DATE IS NOT NULL)
          UNION
          (SELECT 
               S_CONTACT3.ROW_ID AS [contactID],S_CONTACT3.X_MRP_EMAIL_VERIFIED_DATE AS [date], 
                                'MRPEmailVerification' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    S_CONTACT2.ACCOUNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore],NULL AS [QCApproved],
                                    NULL AS [HQL_ID],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM Reporting.dbo.S_CONTACT_X AS [S_CONTACT3]
                            LEFT JOIN AnalyticsDB.dbo.V_S_CONTACT_full AS [S_CONTACT2]
                                  ON S_CONTACT3.ROW_ID =S_CONTACT2.CONTACT_ID
                            WHERE S_CONTACT3.X_MRP_EMAIL_VERIFIED_DATE IS NOT NULL)
                        UNION
                            (SELECT S_CONTACT3.ROW_ID AS [contactID],S_CONTACT3.X_DIRECT_DIAL_VERIFIED_DATE AS [date], 
                                'DirectDialVerification' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    S_CONTACT2.ACCOUNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore],NULL AS [QCApproved],
                                    NULL AS [HQL_ID],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM Reporting.dbo.S_CONTACT_X AS [S_CONTACT3]
                            LEFT JOIN AnalyticsDB.dbo.V_S_CONTACT_full AS [S_CONTACT2]
                                  ON S_CONTACT3.ROW_ID =S_CONTACT2.CONTACT_ID
                            WHERE S_CONTACT3.X_DIRECT_DIAL_VERIFIED_DATE IS NOT NULL)
                        UNION
                            (SELECT S_CONTACT3.ROW_ID AS [contactID],S_CONTACT3.X_JOB_TITLE_VERIFIED_DATE AS [date], 
                                'JobVerification' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    S_CONTACT2.ACCOUNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore],NULL AS [QCApproved],
                                    NULL AS [HQL_ID],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM Reporting.dbo.S_CONTACT_X AS [S_CONTACT3]
                            LEFT JOIN AnalyticsDB.dbo.V_S_CONTACT_full AS [S_CONTACT2]
                                  ON S_CONTACT3.ROW_ID =S_CONTACT2.CONTACT_ID
                            WHERE S_CONTACT3.X_JOB_TITLE_VERIFIED_DATE IS NOT NULL)
                        UNION
                            (SELECT S_CONTACT4.CONTACT_ID AS [contactID],S_CONTACT4.X_MEETING_BOOKED_DT AS [date], 
                                'MeetingBooked' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    S_CONTACT4.ACCOUNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore],NULL AS [QCApproved],
                                    NULL AS [HQL_ID],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM AnalyticsDB.dbo.V_S_CONTACT AS [S_CONTACT4]
                            WHERE S_CONTACT4.X_MEETING_BOOKED_DT IS NOT NULL)
                        UNION
                            (SELECT V_S_OPPORTUNITIES.ContactID AS [contactID],V_S_OPPORTUNITIES.Meeting_Date AS [date], 
                                'MeetingBooked' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    V_S_OPPORTUNITIES.Account_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], V_S_OPPORTUNITIES.QC_APPROVED AS [QCApproved],
                                    NULL AS [HQL_ID],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM [AnalyticsDB].[dbo].[V_S_OPPORTUNITIES]
                            WHERE V_S_OPPORTUNITIES.Meeting_Date IS NOT NULL                           
                            )
                        UNION
                            (SELECT COMM.PR_CON_ID AS [contactID],HQL.CREATED AS [date], 
                                'HQL' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    COMM.ACCNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    HQL.ROW_ID AS [HQL_ID],COMM.X_MRP_HQL_QC_STAT AS [QCApproved],
                                    COMM.RESP_TYPE_CD, COMM.STATUS_CD,NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM SiebProd.dbo.CX_MRP_HQL_RESP AS [HQL]            
                            LEFT JOIN Reporting.dbo.S_COMMUNICATION AS [COMM] 
                                ON COMM.ROW_ID = HQL.PAR_ROW_ID
                                WHERE HQL.CREATED IS NOT NULL)
                        UNION 
                            (SELECT NULL AS [contactID],V_Opty_Incl_QcPendRw_lgTopic.CREATED AS [date], 
                                'Opportunity' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    V_Opty_Incl_QcPendRw_lgTopic.Acct_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],NULL AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD], V_Opty_Incl_QcPendRw_lgTopic.ROW_ID AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM [AnalyticsDB].[dbo].[V_Opty_Incl_QcPendRw_lgTopic]
                            WHERE V_Opty_Incl_QcPendRw_lgTopic.CREATED IS NOT NULL) 
                        UNION 
                            (SELECT V_NGIS_OPTY.CONTACT_ID AS [contactID],V_NGIS_OPTY.DATE AS [date], 
                                'Opportunity' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    V_NGIS_OPTY.ACCOUNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],NULL AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD], V_NGIS_OPTY.OPTY_ID AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM [AnalyticsDB].[dbo].[V_NGIS_OPTY]
                            WHERE V_NGIS_OPTY.DATE IS NOT NULL) 
                        UNION 
                            (SELECT V_S_OPPORTUNITIES.ContactID AS [contactID],V_S_OPPORTUNITIES.OPTY_CREATED AS [date], 
                                'Opportunity' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    V_S_OPPORTUNITIES.Account_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],NULL AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD], V_S_OPPORTUNITIES.OPTY_ID AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM [AnalyticsDB].[dbo].[V_S_OPPORTUNITIES]
                            WHERE V_S_OPPORTUNITIES.OPTY_CREATED IS NOT NULL) 
                          UNION
                            (SELECT V_S_LEAD_FUTURES.[Contact ID] [contactID],V_S_LEAD_FUTURES.[Response Date] AS [date], 
                                'LeadFuture' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    V_S_LEAD_FUTURES.[Account ID] AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],NULL AS [QCApproved],
                                    V_S_LEAD_FUTURES.[Response Type] AS [RESP_TYPE_CD], V_S_LEAD_FUTURES.[Response Status] AS [STATUS_CD], NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM [AnalyticsDB].[dbo].[V_S_LEAD_FUTURES]
                            WHERE V_S_LEAD_FUTURES.[Response Date] IS NOT NULL) 
                        UNION
                            (SELECT DISTINCT act.PR_CON_ID AS [contactID],act.TODO_PLAN_START_DT AS [date], 
                                'NGISCall' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    CON.ACCOUNT_ID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],NULL AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD],
                                    NULL AS [STATUS_CD], NULL AS [OptyID],
                                    act.COMMENTS AS [Disposition],act.X_CALL_DISPOSITION AS [SubDisposition],
                                    Timezone.NAME AS [AETimezone]
                            FROM SiebProd.DBO.S_EVT_ACT AS [Act]
                        INNER JOIN SiebProd.dbo.S_CONTACT AS [Contact] 
                                ON Contact.ROW_ID=Act.CREATED_BY
                        INNER JOIN AnalyticsDB.dbo.V_S_CONTACT_w_MOBILE_NUM AS [con] 
                                ON con.CONTACT_ID = act.PR_CON_ID
                        INNER JOIN SiebProd.dbo.S_TIMEZONE AS [Timezone] 
                                ON Timezone.ROW_ID=Contact.TIMEZONE_ID
                        WHERE 
                            Act.TODO_CD='Call Disposition' AND Act.COMMENTS IS NOT NULL AND Act.REF_NUM IS NOT NULL AND Act.X_CALL_DISPOSITION IS NOT NULL 
                            AND Act.X_DISPOSITION_FLG='Y' AND act.PR_CON_ID IS NOT NULL)
                        UNION
                            (SELECT V_S_DMLEAD.[Contact ID] [contactID],
                              CASE
                                WHEN V_S_DMLEAD.[Last Login] > V_S_DMLEAD.[First Login] 
                                THEN V_S_DMLEAD.[Last Login]
                                ELSE V_S_DMLEAD.[First Login] 
                                    END AS [date],
                                'DirectMailOpty' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    V_S_DMLEAD.[Account ID] AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],V_S_DMLEAD.[QC Approved] AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], V_S_DMLEAD.Status AS [STATUS_CD],
                                    NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM [AnalyticsDB].[dbo].[V_S_DMLEAD]
                            WHERE V_S_DMLEAD.[Last Login] IS NOT NULL OR V_S_DMLEAD.[First Login] IS NOT NULL) 
                        UNION
                            (SELECT NULL AS [contactID],
                                CASE
                                WHEN RPT_JAIME_NEW.StartDate > RPT_JAIME_NEW.EndDate
                                THEN RPT_JAIME_NEW.StartDate
                                ELSE RPT_JAIME_NEW.EndDate
                                    END AS [date],
                                'DirectMailOpty' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    RPT_JAIME_NEW.AccountID AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],NULL AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], RPT_JAIME_NEW.Status AS [STATUS_CD],
                                    NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM Reporting.dbo.RPT_JAIME_NEW
                            WHERE (RPT_JAIME_NEW.StartDate IS NOT NULL OR RPT_JAIME_NEW.EndDate IS NOT NULL) AND RPT_JAIME_NEW.Type ='Direct Mail') 
                        UNION 
                            (SELECT CSVendorMasterValidData.[Contact ID] AS [contactID],
                                CSVendorMasterValidData.[Lead Generation Date] AS [date],
                                'ContentSyndicationOpty' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    CSVendorMasterValidData.[Siebel Account ID] AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],CSVendorMasterValidData.[QC Approved] AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],
                                    NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM Reporting.dbo.CSVendorMasterValidData
                            WHERE CSVendorMasterValidData.[Lead Generation Date] IS NOT NULL) 
                        UNION 
                            (SELECT CSVendorMasterInvalidData.[Contact ID] AS [contactID],
                                CSVendorMasterInvalidData.[Lead Generation Date] AS [date],
                                'ContentSyndicationOpty' AS [event],
                                    NULL AS [hasEmail_FLG],
                                    NULL AS [CUST_STAT_CD] , NULL AS [SUPPRESS_EMAIL_FLG], NULL AS [SUPPRESS_CALL_FLG], 
                                    NULL AS [SUPPRESS_MAIL_FLG],NULL AS [ACTIVE_FLG],
                                    CSVendorMasterInvalidData.[Siebel Account ID] AS [accntID],NULL AS [WORK_PHONE_NUM],
                                    NULL AS [MAIN_PHONE_NUM],NULL AS[JOB_ROLE],NULL AS [JOB_FUNCTION],
                                    NULL AS [hasPhone_FLG],
                                    NULL AS [workPhoneSuperScore], 
                                    NULL AS [HQL_ID],CSVendorMasterInvalidData.[QC Approved] AS [QCApproved],
                                    NULL AS [RESP_TYPE_CD], NULL AS [STATUS_CD],
                                    NULL AS [OptyID],
                                    NULL AS [Disposition],NULL AS [SubDisposition],
                                    NULL AS [AETimezone]
                            FROM Reporting.dbo.CSVendorMasterInvalidData
                            WHERE CSVendorMasterInvalidData.[Lead Generation Date] IS NOT NULL)
                        ) AS [timeseries]
                        WHERE timeseries.date >2007 AND timeseries.date <= GETDATE()

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题