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 -> SQL sum() problem

SQL sum() problem

From: Ken <ken_douglas_at_not1.demon.co.uk>
Date: Tue, 28 Jul 1998 22:35:33 +0100
Message-ID: <901661739.8030.0.nnrp-05.d4e4a6b7@news.demon.co.uk>


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 Jul 28 1998 - 16:35:33 CDT

Original text of this message

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