Running Sum In query [message #372860] |
Wed, 14 March 2001 13:13 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Hari
Messages: 59 Registered: August 2000
|
Member |
|
|
My data
Period Value.
1 2000
2 4500
3 5000
4 3200
5 2000
I need a select statement to select period,value, value1( which is running sum sof value).
The result of query should be as follows
Period Value. Running_Value
1 2000 2000
2 4500 6500
3 5000 11500
4 3500 15000
5 2000 17000
|
|
|
Re: Running Sum In query [message #372861 is a reply to message #372860] |
Wed, 14 March 2001 14:35 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Joachim Lindner
Messages: 30 Registered: February 2001
|
Member |
|
|
Hi Hari,
do me a facour an check this statement. Unfortunlately I have no Oracle available, here.
It should solve your problem. It's doing that, at least in my mind :-)
select t1.period, t1.value, sum(t2.value)
from mytab t1, mytab t2
where t1.period >= t2.period
group by t1.period, t1.value;
|
|
|
|
|
|
Re: Running Sum In query [message #372878 is a reply to message #372869] |
Thu, 15 March 2001 07:12 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
balu
Messages: 23 Registered: March 2001
|
Junior Member |
|
|
Hai joachim,
your query is correct when u have two tables,
but the question is only one table,
Table name:t1
a b
-------
1 2000
2 4000
3 6000
4 8000
5 10000
The output should be
a b sum(b)
------------
1 2000 2000
2 4000 6000
3 6000 12000
4 8000 18000
5 10000 28000
So if u know the query for this table, please give it. Although your query is correct if i have
two tables, but this is only one table.
|
|
|
|
Re: Running Sum In query [message #372883 is a reply to message #372869] |
Thu, 15 March 2001 10:36 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
Hari
Messages: 59 Registered: August 2000
|
Member |
|
|
hi balu and Joachim Lindner
The query works fine . Using PL/SQl is not probs i have done that.
I wnated to know if you both have come across any new analytical functions of oracle 8 or 8i
Thanks
HAri
|
|
|