Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Perform Arithmetic On Case Statement Decisions

Perform Arithmetic On Case Statement Decisions

From: jim <jimmorgan76_at_gmail.com>
Date: 19 Feb 2007 06:20:40 -0800
Message-ID: <1171894840.446123.249530@h3g2000cwc.googlegroups.com>


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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US