Home » RDBMS Server » Server Administration » how to write a sql like this ?
how to write a sql like this ? [message #372903] Fri, 16 March 2001 13:28 Go to next message
Oranewbie
Messages: 2
Registered: March 2001
Junior Member
select title,'classification'=CASE
When price<10 then 'low'
When price>20 then 'High'
else 'normal'
end
from titles

this sql can run at sql server 7.0,how to write a sql like this in oralce 7.3?
please help me
Re: how to write a sql like this ? [message #372905 is a reply to message #372903] Fri, 16 March 2001 14:22 Go to previous messageGo to next message
Andrew again...
Messages: 270
Registered: July 2000
Senior Member
See the "Re: Decode help" further down in this disussion group
Re: how to write a sql like this ? [message #372910 is a reply to message #372903] Fri, 16 March 2001 21:11 Go to previous message
balu
Messages: 23
Registered: March 2001
Junior Member
Hi,

you can do this in oracle 8i. The format is

select sal,case when sal<1000
then 'sal is less than 1000'
else 'sal is more than 1000'
end from emp;

try this in 8i, but it won't work in 7.3.

If you want do this function use decode in 7.3

select sal, decode(abs(sal-1001),sal-1001,'Sal is greater than 1000','Sal is less than or equal to 1000');

With Regards,
Balu
Previous Topic: Raise_Application_ Error
Next Topic: table access
Goto Forum:
  


Current Time: Sat Jun 29 13:51:19 CDT 2024