CASE expresion in sql

Ij
Posted by Ij under Oracle category on | Points: 40 | Views : 334
Case expression is using to provides multiple conditions with respective resultant values.if no condition is satisfied returns default statement.

EXAMPLE : to display the increment Sal particular jobs BY using case expression

SELECT ENAME,JOB, CASE JOB
WHEN 'MANAGER' THEN SAL * 0.18+SAL
WHEN 'ANALYST' THEN SAL * 0.15+SAL
ELSE SAL * 0.12+SAL
END
"New Sales" FROM EMP;


OUTPUT:

ENAME    JOB            NEW SAL

KING PRESIDENT 5600
BLAKE MANAGER 3363
CLARK MANAGER 2891
JONES MANAGER 3510.5
SCOTT ANALYST 3450
FORD ANALYST 3450
SMITH CLERK 896
ALLEN SALESMAN 1792
WARD SALESMAN 1400

Comments or Responses

Login to post response