开发者

Problem with case and status

开发者 https://www.devze.com 2023-01-15 13:01 出处:网络
When I don\'t have right side I get NULL on column StatusOfDeduplication instead 5. What is wrong with thi开发者_运维百科s query ?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消