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 -> Re: SQL question

Re: SQL question

From: Chris Dixon <cjdixon_at_globalnet.co.uk>
Date: Wed, 9 Sep 1998 14:57:03 +0100
Message-ID: <6t61bj$g1r$1@heliodor.xara.net>


Try :

select sum(decode(type, 'R', amount*-1, amount)) TOTALO from order;

Henrik Staun Poulsen wrote in message <35F67CCD.5104D35F_at_infolog.dk>...
>Dear All,
>
>I want to select the sum of all orders, but I want to subtract the all
>the sale reversals, i.e. all orders that where canceled out.
>Do I need to create a union like
>
>create view test as
> select sum(amount) 'TotalO' from order where Type = 'S'
> UNION
> select (sum(amount) * (-1)) 'TotalO' from order where Type = 'R'
>
>select TotalO from test
>
>OR is there a way of writing the select statement with an IF statement
>or a CASE statement?
>
>TIA
>
>Henrik Staun Poulsen
>InfoLog
>
>
>
>
>
Received on Wed Sep 09 1998 - 08:57:03 CDT

Original text of this message

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