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