Oracle條件表達式


/*

   條件表達式  sql語句數據庫通用表達式

     case 列

       when 列值1 then  顯示值1

       when 列值2 then  顯示值2

       when 列值3 then  顯示值3

     else

       默認值

     end  

   orace特有條件表達式

   decode(列,列值1,顯示值1,列值2,顯示值2,默認值)  

*/

select e.empno emp_no,e.ename emp_name,d.dname,

    case s1.grade

      when 1 then '一級'

      when 2 then '二級'

      when 3 then '三級'

      else

        '四級'

    end emp_grade

    ,

    m.empno mgr_no,m.ename mgr_name ,

    decode(s2.grade,3,'三級',4,'四級','五級') mgr_grade

    from emp e,emp m,dept d ,salgrade s1,salgrade s2

    where

    e.mgr = m.empno and e.deptno = d.deptno

    and e.sal  between s1.losal and s1.hisal

    and m.sal  between s2.losal and s2.hisal


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM