Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
232 views
in Technique[技术] by (71.8m points)

How to avoid default date 1900-01-01 in SQL Server 2008 R2 during join statement

SELECT IsNull(cmg.[Advertiser],
    con.[Advertiser]) as [Advertiser] ,
    IsNull(cmg.[AdvertiserID],
    con.[AdvertiserID]) as [AdvertiserID] ,
    con.[FloodlightConfiguration] ,
    IsNull(cmg.[Campaign],
    con.[Campaign]) as [Campaign] ,
    IsNull(cmg.[CampaignID],
    con.[CampaignID]) as [CampaignID] ,
    IsNull(cmg.[Placement],
    con.[Placement]) as [Placement] ,
    IsNull(cmg.[PlacementID],con.[PlacementID]) as [PlacementID] ,
    IsNull(cmg.[Creative],con.[Creative]) as [Creative] ,
    IsNull(cmg.[CreativeID],con.[CreativeID]) as [CreativeID] ,
    IsNull(cmg.[AD],con.[AD]) as [AD] ,
    IsNull(cmg.[ADID],
    con.[ADID]) as [ADID] ,
    IsNull(cmg.[Country],
    con.[Country]) as [Country] ,
    con.[Activity] ,
    con.[ActivityID] ,
    IsNull(cmg.[DeliveryDate],0) as [ConversionDate] ,
    IsNull(con.[TotalConversions],0) as [TotalConversions] ,
    IsNull(con.[TotalRevenue],0) as [TotalRevenue] ,
    IsNull([ClickthroughConversions],0) as [ClickthroughConversions] ,
    IsNull([ClickthroughRevenue],0) as [ClickthroughRevenue] ,
    IsNull([ViewthroughConversions],0) as [ViewthroughConversions] ,
    IsNull([ViewthroughRevenue],0) as [ViewthroughRevenue] ,
    case when con.[ActivityID] is not null then 0 else cmg.Impressions end as Impressions,
    case when con.[ActivityID] IS NOT Null then 0 else cmg.Clicks end AS Clicks,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.MediaCost end as MediaCost,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.ActivityPerClick end as ActivityPerClick,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.ActivityPerThousandImpressions end as ActivityPerThousandImpressions,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.CostPerActivity end as CostPerActivity,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.CostPerClick end as CostPerClick,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.CostPerRevenue end as CostPerRevenue,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.EffectiveCPM end as EffectiveCPM ,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.RevenuePerClick end as RevenuePerClick,
    case when con.[ActivityID] IS NOT NULL then 0 else cmg.RevenuePerThousandImpressions end as RevenuePerThousandImpressions 
FROM [DM_886_MarriottSocialData].[dbo].[DFA_BSE_DIS_MD_1] cmg
    FULL OUTER JOIN [DM_886_MarriottSocialData].[dbo].[DFA_BSE_DIS_CON_1] con
        ON cmg.PlacementID = con.PlacementID 
            AND cmg.DeliveryDate = con.ConversionDate 
            AND cmg.CampaignID = con.CampaignID 
            AND cmg.Country = con.Country 
            AND cmg.ADID = con.ADID 
            AND cmg.CreativeID = con.CreativeID 
            AND cmg.AdvertiserID = con.AdvertiserID 
WHERE cmg.DeliveryDate >= '2014-01-01' 
    AND cmg.DeliveryDate <= '2014-03-16'

This is the code I am using currently to evaluate aggregate table but i am getting 1900-01-01 default date in some records. however, i want those all records in final table. The reason is because of 1900-01-01 some columns are effecting with 5%-10% of fluctuation in their respective values.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...