sql-case,when的多条件组合写法

1.decode 写法简介,只能写表达式。

例:decode(表达式,条件1,值1,条件2,值2··· 默认值) 

无法满足多条件的写法,比如,我要a-b = 0 且a !=0 用decode没法实现

2.case when 能写多条件

写法一:case 表达式 when 条件1 then 值1

                                   when 条件2 then 值2

                                  ····

                                  else 值  end

写法二:case when a-b=0 and a != 0 then 值

                        when  ··· then ···

                        else  值  end

猜你喜欢

转载自blog.csdn.net/wrongyao/article/details/81081778