Home » SQL & PL/SQL » SQL & PL/SQL » DECODE Function
DECODE Function [message #389] Fri, 08 February 2002 13:38 Go to next message
Vidette P
Messages: 3
Registered: February 2002
Junior Member
I have tried adding ELSIF and ENDIf but I still getORA-00933: SQL command not properly ended

SELECT job, sal FROM emp
DECODE (IF job = 'ANALYST' THEN SAL = sal*1.1
IF job = 'CLERK' THEN SAL = sal*1.15
IF job = 'MANAGER' THEN SAL = sal*1.20
ELSE sal = sal) As "Revised Salary"
BUT I GET
ERROR at line 2:
ORA-00933: SQL command not properly ended
I have tried adding ELSIF but I still getORA-00933: SQL command not properly ended , Any idea why? :(
Thanks,
Re: DECODE Function [message #398 is a reply to message #389] Sun, 10 February 2002 05:42 Go to previous messageGo to next message
Suresh Vemulapalli
Messages: 624
Registered: August 2000
Senior Member
SELECT job, sal
DECODE (job,'ANALYST' ,to_char(sal*1.1),'CLERK',to_char(sal*1.15),
'MANAGER',to_char(sal*1.20),to_char(sal)) As "Revised Salary"
FROM emp
Re: DECODE Function [message #404 is a reply to message #389] Mon, 11 February 2002 00:35 Go to previous message
Abul Fazal
Messages: 39
Registered: February 2002
Member
Select job,
decode(
job, 'ANALYST', sal*1.1,
'CLERK', sal*1.2,
'MANAGER', sal*1.3,
'PRESIDENT', sal*1.4,
'SALESMAN', sal*1.5, SAL
) "RISE"
from emp a
where rowid = ( Select max(rowid) from emp b
where a.job = b.job)

HAPPY CHINESE NEW YEAR to all the chinese friends
Abul Fazal
Previous Topic: Re: deleting column from table?
Next Topic: select statement
Goto Forum:
  


Current Time: Thu Aug 06 01:52:40 CDT 2020