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

 

posted @ 2020-03-04 16:09  hello-*-world  阅读(12221)  评论(0编辑  收藏  举报