Full outer join not returning all rows?

后端 未结 2 1007
名媛妹妹
名媛妹妹 2020-12-12 05:06

I have a table that contains multiple records for multiple dates.

I am trying to see the difference between \"date 1\" and \"date 2\" and my full outer join is not r

2条回答
  •  鱼传尺愫
    2020-12-12 06:03

    The where is killing the outer join.
    A column cannot be both null and = to a value.
    Put the conditions in the join.

    SELECT COALESCE(c.AccountBranch, p.AccountBranch)
         , COALESCE(c.AccountNumber, p.AccountNumber)
         , COALESCE(c.AccountSuffix, p.AccountSuffix)
         , c.PrincipleAmount, p.PrincipleAmount
    FROM            cb_account_extension_principle_dpd c
    FULL OUTER JOIN cb_account_extension_principle_dpd p
      ON p.AccountBranch = c.AccountBranch
     AND p.AccountNumber = c.AccountNumber 
     AND p.AccountSuffix = c.AccountSuffix
     AND c.BusinessDataDate = @CurrentBusinessDataDate
     AND p.BusinessDataDate = @PreviousBusinessDataDate
    

提交回复
热议问题