开发者

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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜