Problem with case and status
When I don't have right side I get NULL on column StatusOfDeduplication instead 5.
What is wrong with thi开发者_运维百科s 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
NULL cannot be compared using equal or CASE WHEN. Use
ISNULL(cp.TargetCodeStatus, 5) AS StatusOfDeduplication
instead
精彩评论