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

Home -> Community -> Usenet -> c.d.o.server -> Re: SQL sum() problem

Re: SQL sum() problem

From: Monique van Daal <mvdaal_at_arisco.nl>
Date: Tue, 15 Dec 1998 17:29:13 GMT
Message-ID: <35bf2df4.26424434@news.atriserv.nl>


On Tue, 28 Jul 1998 22:35:33 +0100, "Ken" <ken_douglas_at_not1.demon.co.uk> wrote:

I think you want to group by period instead of branch, period_no etc. when you select period_no, sum(...) from... where.... group by period_no you will find the sum of the period_no's for each period asked.

good luck

>I have one table that contains :_
>
>BRANCH
>PERIOD_NO
>GROSS_SALES
>OPENING_VALUE
>CLOSING_VALUE
>etc...
>
>I want to select the summed values of GROSS_SALES for the selected period
>range.
>User wants period 1 they just get period 1, user wants period 2 they get
>period 1 plus period 2.
>The problem lies with the WHERE clause:-
>
>
> ..
> ..
> WHERE period BETWEEN 1 and :period_no
>
>What happens is that I get 1 row plus the extrac period_no's
>
>What would be nice is to say
> select sum(gross_sales for group 1)
> from tableX
> where period_no BETWEEN 1 and :period_no
> group by BRANCH, PERIOD, GROSS_SALES
>
>
>this just sums up period 1 (there is only one record per BRANCH per PERIOD
>anyway!) then
>sums up period 2 etc...
>
>What I want to do is simple, sum() up the gross_sales for the range of
>periods requested.
>
>Many many thanks in advance
>
>
>--
>__________
><en
>
>Power Users do it on one hand!
>
>
>
Received on Tue Dec 15 1998 - 11:29:13 CST

Original text of this message

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