views:

7

answers:

1

When I don't have right side I get NULL on column StatusOfDeduplication instead 5.

What is wrong with this query ?

select c.Code AS Code, c.DefaultName AS Name, c.Status AS Status,
 case cp.TargetCodeStatus when Null then 5  else cp.TargetCodeStatus end as StatusOfDeduplication from Cities c LEFT JOIN CityPackages cp ON cp.TargetCode = c.Code
+1  A: 

NULL cannot be compared using equal or CASE WHEN. Use

ISNULL(cp.TargetCodeStatus, 5) AS StatusOfDeduplication 

instead

devio
great, thank You !