running total [message #430409] |
Tue, 10 November 2009 05:52  |
mohan1760
Messages: 59 Registered: June 2008
|
Member |
|
|
In below example column 2 and 3 are coming from one table.
i want to implement first column something like shown in below example...same as running total
in column 1 but first record of column 1 should start with 3.
after that 3+8=11,11+1=12...and so on....
3 8 NUMBER
11 1 Alpha9
12 8 Alpha9
20 6 Alpha9
26 8 NUMBER
Thanks in advance..
|
|
|
Re: running total [message #430411 is a reply to message #430409] |
Tue, 10 November 2009 06:00   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Show us what the data that you want to start with is, and what the data that you want to end up with is.
|
|
|
Re: running total [message #430416 is a reply to message #430411] |
Tue, 10 November 2009 06:08   |
mohan1760
Messages: 59 Registered: June 2008
|
Member |
|
|
start with
8 NUMBER
1 Alpha9
8 Alpha9
6 Alpha9
8 NUMBER
end with
3 8 NUMBER
11 1 Alpha9
12 8 Alpha9
20 6 Alpha9
26 8 NUMBER
the thing which creats problem
is that i want to start running total by 3 not by 1...after that it is easy to manipulate...fyi first column is dummy column for calculation.
|
|
|
|
|
|
Re: running total [message #430426 is a reply to message #430421] |
Tue, 10 November 2009 06:25   |
JRowbottom
Messages: 5933 Registered: June 2006 Location: Sunny North Yorkshire, ho...
|
Senior Member |
|
|
Quote:how to send insert statements?...
That's funny.
create table test_097 (col_1 number, col_2 number, col_3 varchar2(30),ord number);
insert into test_097 values (null,8 ,'NUMBER',1);
insert into test_097 values (null,1 ,'Alpha9',2);
insert into test_097 values (null,8 ,'Alpha9',3);
insert into test_097 values (null,6 ,'Alpha9',4);
insert into test_097 values (null,8 ,'NUMBER',5);
commit;
select col_1
,col_2
,col_3
, nvl(sum(col_2) over (order by ord rows between unbounded preceding and 1 preceding) ,0) + 3
from test_097;
|
|
|
|
|