Sqlserver 中case when 的详细用法总结


一.

 case [字段]
         when '要比较的值' then 表达式
         when '要比较的值' then 表达式
         else ''
      end 

示例

select 
(case ApplyAmount
when null then 0 --判断为空时,取0
else ApplyAmount end) as ApplyAmount
from HTFKApply

二.

case 
    when [条件] then 表达式
    when [条件] then 表达式
    else ''
 end 

示例

select
case when (a.ApplyAmount is null) then 0
else a.ApplyAmount end as ApplyAmount from HTFKApply

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM