Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Perform Arithmetic On Case Statement Decisions
Hi,
I have a case statement that's kind of like this:
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
This takes two columns of alphabetic strings and yields columns of numeric values (before and after values). I'm currently running the query and then doing the math in Excel after the fact (after minus before).
Is there any way to perform a calculation on the output of a case statement *in* the select query itself? Ideally this would return another column containing the value of after-before.
Thanks in advance.
jim Received on Mon Feb 19 2007 - 08:20:40 CST