如何在sql中格式化这个case语句?

时间:2013-06-21 16:49:01

标签: sql switch-statement case

基本上,如果Field Blue为1,我想返回'Y',如果不是,则返回空白。我应该怎么做呢?

Case isnull(Blue, 'N') when Blue = 'Y' then 1 else '' end

2 个答案:

答案 0 :(得分:1)

您的空检查是多余的。您只需要测试'Y'

Case when Blue = 'Y' then '1' else '' end

答案 1 :(得分:-1)

你可以做任何一件事

Case isnull(Blue, 'N') when 'Y' then '1' else '' end

Case when isnull(Blue, 'N') = 'Y' then '1' else '' end

请参阅case

相关问题