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
原文地址:https://www.cnblogs.com/HTLucky/p/12410114.html