Sql Server where case 满足条件执行 不满足 不做任何条件查询

来源:互联网 发布:ant 运行java 编辑:程序博客网 时间:2024/05/22 12:14

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)


0 0