Decode function in Oracle

Bubbly
Posted by Bubbly under Others category on | Views : 3148
Decode facilitates conditional inquiries by working same as CASE or IF-THEN-ELSE statement.

Syntax :
DECODE (col|expression, search1, result1 [,search2,result2,...,] [,default])


Suppose I have a table called Employee with following data
Employee 
Firstname Lastname Jobcode salary
Meena Kumar IT_PRG 10000
Kohil Sharma CLERK 5000
Ritu Mehta HR 12000


now using Decode function on this table
SELECT Lastname,Jobcode,salary,DECODE(Jobcode,'IT_PRG','1.10*salary', 'CLERK','1.15*salary','HR','1.20*salary') Revised_salary FROM Employee


Output
Lastname Jobcode Revised_salary 
Kumar IT_PRG 11000
Sharma CLERK 5750
Mehta HR 14400

Comments or Responses

Login to post response