Decode function in Oracle

Posted by Bubbly under Others category on | Views : 3430
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
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

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

Comments or Responses

Login to post response