Sql Server where case 滿足條件執行 不滿足 不做任何條件查詢

sql 裏經常用的where語句中可以使用case when

常用的

   select * from tb where a= case when b>0 and b<100 then 1 when b>=100 then 2 else 3 end

滿足條件執行大於某個值,不滿足不執行查詢

 select * from tb   where  ((case when isnull([a],'')<>'' then convert(numeric(10,2),isnull([a],'0')) else 4000 end)>100)


發佈了83 篇原創文章 · 獲贊 21 · 訪問量 33萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章