Home » RDBMS Server » Server Administration » case
case [message #374844] Thu, 05 July 2001 23:22 Go to next message
ravibabu
Messages: 12
Registered: July 2001
Junior Member
how do we use CASE in oracle?
if i am using case like this i am gettting the following error

SQL> SELECT ename, CASE WHEN sal>1000 THEN 'Over paid' ELSE 'Under paid' END
2 FROM emp;
SELECT ename, CASE WHEN sal>1000 THEN 'Over paid' ELSE 'Under paid' END
*
ERROR at line 1:
ORA-00923: FROM keyword not found where expected
Re: case [message #374845 is a reply to message #374844] Thu, 05 July 2001 23:37 Go to previous messageGo to next message
Rajasekar.N
Messages: 3
Registered: July 2001
Junior Member
Use Decode function in Oracle. It would be like this:

SELECT ename, DECODE(sign(sal-1000),1,'Over Paid','Under Paid') SalCategory FROM emp;
Re: case [message #374847 is a reply to message #374844] Fri, 06 July 2001 02:22 Go to previous messageGo to next message
Hans
Messages: 42
Registered: September 2000
Member
Your select statement works under Oracle 8.1.6
and 8.1.7
Re: case [message #374849 is a reply to message #374845] Fri, 06 July 2001 03:40 Go to previous messageGo to next message
Rajasekar.N
Messages: 3
Registered: July 2001
Junior Member
Hans is right, CASE can be used in 8.1.6 and above.

For more details
http://technet.oracle.com/doc/oracle8i_816/server.816/a76994/analysis.htm#14814
Re: case [message #374853 is a reply to message #374844] Fri, 06 July 2001 07:21 Go to previous message
Rajasekar.N
Messages: 3
Registered: July 2001
Junior Member
Hans is right, CASE can be used in 8.1.6 and above.

For more details
http://technet.oracle.com/doc/oracle8i_816/server.816/a76994/analysis.htm#14814
Previous Topic: higest value
Next Topic: Regarding performance Tuning book
Goto Forum:
  


Current Time: Mon Dec 23 19:43:36 CST 2024