Monday, 14 March 2016

How to use decode in where clause ?


select 
       emp.empno
      ,emp.ename
      ,emp.deptno
      ,dept.deptno
      ,dept.dname 
from  emp
     ,dept
where emp.deptno=dept.deptno
  and (decode(emp.deptno,10,'ACCOUNTING')=dept.dname
      or
       decode(emp.deptno,20,'RESEARCH')=dept.dname
      or
       decode(emp.deptno,30,'SALES','OPERATIONS')=dept.dname);

No comments:

Post a Comment

Query to find request set and its responsibility

  SELECT FA.application_name,        fr.responsibility_name program_attached_to,        frg.request_group_name,        fcp.request_set_name,...