https://plsqlquery.blogspot.com/2018/05/using-decode-in-plsql-query.html
Facilitates Conditional inquiries by doing the work of a case or IF-THEN-ELSE Statement:
select ENAME, DEPTNO,
DECODE(DEPTNO,10,'ACCOUNTS',20,'RESEARCH',30,'SALES','INVALID') DNAME
from EMP
where ENAME in ('KING', 'BLAKE', 'SCOTT');
ENAME DEPTNO DNAME
KING 10 ACCOUNTS
BLAKE 30 SALES
SCOTT 20 RESEARCH
select ENAME, JOB, SAL,
DECODE(JOB,'PRESIDENT', SAL*1.15,'MANAGER',SAL*1.12,'ANALYST',SAL*1.1,'SALESMAN',SAL*1.08) "INCREMENT"
from EMP
where ENAME in ('SMITH','ALLEN','JONES','KING','FORD');
ENAME JOB SAL INCREMENT
KING PRESIDENT 5000 5750
JONES MANAGER 2975 3332
FORD ANALYST 3000 3300
SMITH CLERK 800 (null)
ALLEN SALESMAN 1600 1728
select ENAME, JOB, SAL,
DECODE(JOB,'PRESIDENT', SAL*1.15,'MANAGER',SAL*1.12,'ANALYST',SAL*1.1,'SALESMAN',SAL*1.08, SAL) "INCREMENT"
from EMP
where ENAME in ('SMITH','ALLEN','JONES','KING','FORD');
ENAME JOB SAL INCREMENT
KING PRESIDENT 5000 5750
JONES MANAGER 2975 3332
FORD ANALYST 3000 3300
SMITH CLERK 800 800
ALLEN SALESMAN 1600 1728
Subscribe to:
Post Comments (Atom)
XLA to GL Link
https://plsqlquery.blogspot.com/2025/12/xla-to-gl-link.html SELECT acr.cash_receipt_id, acr.receipt_number, ...
-
https://plsqlquery.blogspot.com/2018/05/using-outer-joins-in-plsql-query.html We use Outer Join when mismatched Values to be displayed ...
-
https://plsqlquery.blogspot.com/2018/05/using-trim-in-plsql-query.html The Oracle/PLSQL TRIM function removes all specified characters eit...
-
https://randomsrsolutions.blogspot.com/2018/05/using-trunc-function-with-numbers-in.html The TRUNC function Truncates the Column, Expressi...
No comments:
Post a Comment