Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: views if and case statements
In article <3B4C6F71.55A718D2_at_attws.com>, "Daniel says...
>
>CME wrote:
>
>> I am trying to convert sybase views to oracle views and I cannot find a way
>> to use 'if' or 'case' statements within a view itself
>> if there is any way this can be done or can be worked around please contact
>> me
>> thank you for any help
>
>Look at the DECODE function. That is as close as you can get.
>
>Daniel A. Morgan
>
short of using case maybe?
1 create or replace view emp_view
2 as
3 select ename, empno, case when (sal < 100) then 'low' 4 when (sal between 101 and 500) then 'med' 5 when (sal between 501 and 1000) then 'high' 6 else 'really high' 7 end Salary
View created.
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Wed Jul 11 2001 - 11:50:57 CDT