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: <bhogak_at_my-dejanews.com>
Date: Fri, 11 Sep 1998 22:34:36 GMT
Message-ID: <6tc8ht$urp$1@nnrp1.dejanews.com>


Dear Mr. Poulsen,
If you are looking for the net amount, try this select statement: select sum(sum(amount*decode(type,'S',1,'R',-1,1))) from order group by amount,type;
Best wishes,
Kumar

In article <35F67CCD.5104D35F_at_infolog.dk>,   Henrik Staun Poulsen <hsp_at_infolog.dk> wrote:
> 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
>
>

-----== Posted via Deja News, The Leader in Internet Discussion ==----- http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum Received on Fri Sep 11 1998 - 17:34:36 CDT

Original text of this message

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