Hi there,
I have a table which contains lots of records. I use sqlplus to spool the result.
set newpage 0 feedback off
set pagesize 15 linesize 100
break on grp skip page
compute sum of amt on grp
with table_sales (id,grp,amt) as (
select 1,1,10 from dual
union all select 1,1,10 from dual
union all select 2,1,20 from dual
union all select 3,1,30 from dual
union all select 4,1,40 from dual
union all select 5,2,50 from dual
union all select 6,2,60 from dual
union all select 7,2,70 from dual
union all select 8,2,80 from dual
union all select 9,2,90 from dual
union all select 10,2,100 from dual
)
select id,grp,amt from table_sales;
<Page1>
ID GRP AMT
---------- ---------- ----------
1 1 10
1 10
2 20
3 30
4 40
********** ----------
sum 110
<Page 2>
ID GRP AMT
---------- ---------- ----------
5 2 50
6 60
7 70
8 80
9 90
10 100
********** ----------
sum 450
How can I put the summary 110 on Page 1 to the bottom of Page 2 as carry forward summary and add up together?
<Page 2>
ID GRP AMT
---------- ---------- ----------
5 2 50
6 60
7 70
8 80
9 90
10 100
********** ----------
sum 450 Sub-Total on Page 2
110 CARRY FWD TOTAL on Page 1
TOTAL 560 Grand Total on Page 2
Is that possible? It might not only 2 pages, might be many pages.
Any help or hints will be appreciated.
Phil