Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> SQL sum() problem
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
--
Power Users do it on one hand! Received on Tue Jul 28 1998 - 16:35:33 CDT
![]() |
![]() |