两种实现多条件判断的case when 方法
// An highlighted block
select (case when 条件 and 条件 then 0 when 条件 and 条件 then 1 else 2 end) as name from table
select count = (case when 条件 and 条件 then 0 when 条件 and 条件 then 1 else 2 end) from table
SQLServer2005 CASE WHEN的两种用法
第一种:普通的CASE 函数
case sex
when ‘1’ then ‘数字1’
when ‘2’ then ‘数字2’
else ‘不是1也不是2’
end as num
第二种:CASE 搜索函数
case
when sex=‘1’ then ‘数字1’
when sex=‘2’ then ‘数字2’
else ‘不是1也不是2’
end as num
最后
以上就是义气网络最近收集整理的关于SQL Server中用Case When Then多条件判断sql的全部内容,更多相关SQL内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复