Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Is it possible to subtract case statements
On Feb 14, 10:30 am, "MrHelpMe" <clintto..._at_hotmail.com> wrote:
> Hello all,
>
> I am wondering if it is possible to subtract case statements in oracle
> 9.2? If it is, could someone please show me how. This is basically
> what I am using for my case statements:
>
> [code]
>
> SELECT
> (Case when field1 = 'hello' then 1 else 0 END)Case1,
> (case when field2='test' then 1 else 0 END)Case2,
> FROM Table x;
>
> [/code]
>
> So I would get the resultset as such:
>
> Case1 Case2 Result
> 1 1 0
> 0 0 0
> 1 0 0
> 0 1 -1
>
> Any ideas. Thanks so much
Couldn't you have tested this yourself?
ORA92> select
(case when a = 'too lazy to test' then 1 else 0 end) + (case when b = 'myself' then 1 else 0 end) from test5;
(CASEWHENA='TOOLAZYTOTEST'T
2
Anurag Received on Wed Feb 14 2007 - 09:56:13 CST