Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Perform Arithmetic On Case Statement Decisions
On Feb 21, 4:00 pm, "jim" <jimmorga..._at_gmail.com> wrote:
> Thanks, Ed. So what would this look like inline? I'm an Oracle
> novice, so elementary advice is appreciated.
>
> Thanks again.
select name, after_numeric - before_numeric from (
select name, case when before = 'x' then 1 when before = 'y' then 2 else 3 end as before_numeric, case when after = 'x' then 1 when after = 'y' then 2 else 3 end as after_numeric from table )
Try that. It is an in-line view.
You really should read the manuals. I'll leave the other two options for an exercise. They really aren't much harder that the above. (HINTS: look up CREATE VIEW and CREATE FUNCTION for the second anfd third option respectively)
Have a good read.
Ed
Received on Wed Feb 21 2007 - 15:10:21 CST