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)

  

原文地址:https://www.cnblogs.com/objectnull/p/9378193.html