oracle decode case语法

SELECT col1, col2,   
       CASE   
          WHEN col3 > 1 AND col3 <2   
             THEN '1'   
          WHEN col3 > 2 AND col3 <3   
             THEN '2'   
          WHEN col3 > 3 AND col3 <4   
             THEN '3'   
          ELSE '4'   
       END mylevel   
FROM table    
  
select case   
       when    nsrsbh='330165737758262'   then   nsrsbh  
       when    nsrsbh='330106745808709'    then   nsrsbh   
       else     '99999'  
       end   
from WS_TDS_SQ  

select case    nsrsbh
       when   '330165737758262'  then  nsrsbh  
       when   '330106745808709'    then   nsrsbh   
       else    '99999'  
       end   
from table  
  
decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)  
decode(字段或字段的运算,值1,值2,值3)  
select decode (value, <if this value>, <return this value>) FROM table  
  
select decode(col1,'330165737758262',nsrsbh,'330106745808709',nsrsbh,0) from table 
select decode(col1,'330165737758262','6','9') from table  

猜你喜欢

转载自daydayup0658.iteye.com/blog/1949717