Sub total from group by query?
Hi,
im using oracle 9i.
Im getting results fine for the following kind of query,
select a,b,c,sum(qty) d,sum(val) e from my_table group by a,b,c
Now the output look like this
a b c d e
1 tt rr 10 15
1 tt rr 10 25
1 tt rr 50 50
1 tt rr 10 20
2 tt rr 10 20
2 tt rr 20 40
2 tt rr 30 90
2 tt rr 40 80
3 tt rr 50 100
3 tt rr 60 180
3 tt rr 70 140but i want the output with subtotal based on column a. finally i want grant total. My output should b
a b c d e
1 tt rr 10 15
1 tt rr 10 25
1 tt rr 50 50
1 tt rr 10 20
80 110
2 tt rr 10 20
2 tt rr 20 40
2 tt rr 30 90
2 tt rr 40 80
100 230
3 tt rr 50 100
3 tt rr 60 180
3 tt rr 70 140
180 420
760I tried with rollup,cube and grouping sets. But im not able to get exact result.
Good help will be appreciated.
Regards
Sankar MN
Edited by: SankarMCA on Oct 5, 2010 6:02 AM
This may help you
SQL> ed
Wrote file afiedt.buf
1 SELECT empno,sal,SUM(sal) OVER (order by sal RANGE BETWEEN UNBOUNDED PRECEDING and CURRENT ROW) cumulative_sum
2* FROM emp
SQL> /
EMPNO SAL CUMULATIVE_SUM
7369 800 800
7900 950 1750
7876 1100 2850
7521 1250 5350
7654 1250 5350
7934 1300 6650
7844 1500 8150
7499 1600 9750
7782 2450 12200
7698 2850 15050
7566 2975 18025
EMPNO SAL CUMULATIVE_SUM
7788 3000 24025
7902 3000 24025
7839 5000 29025
14 rows selected.
Similar Messages
-
Creation of Sub-Totals within Groups
Hi - hope this is me just being a plank but I've hit a brick wall whilst trying to recreate a set of management accounts. So far the report has just two Groups - call them A & B for ease. Group B summarizes the detail and Group A neatly collects the results from Group B.
Group A comprises 6 parts all doing their bit and all the standard Crystal Sub-Totals (Summaries) work just fine. The problem I encounter is when I need to insert another Sub-Total into Group A which summarizes multiple parts of Group A e.g. Part 1 is Sales, Part 2 is Cost of sales, Part 3 is Labour, Part 4 is Expenses, Part 5 is Other and Part 6 is Depreciation. I need to insert a Sub-Total between Parts 3 and 4 which basically gives a total of Sales minus Cost of Sales minus Labour and to then continue with Parts 4 to 6. This is obviously a huge simplification of the issue but an answer to this would let me proceed with everything else.
I've tried creating an line so I can add a formula for this by giving it a name of its own in Group A but it fails to appear on the report. I've also tried the 'Insert Section Below' option and whilst I can suppress it where necessary the formula just picks up values from the last entry on the Detail Section.
Any ideas where I am making some elementary mistakes and is there an easy solution? Many thanksHi,
Try to create a manual running total formula for summing the fields with a condition.
Create a @reset formula and place it report header:
formula:
whileprintingrecords;
numbervar i:=0;
Create a @eval formula and place it in group header A:
formula:
whileprintingrecords;
numbervar i;
if {groupname.field} = 'Labour' or {groupname.field} = 'Expenses' then
i:= i + {summary.field};
Create a @display formula and place it in report footer;
formula:
whileprintingrecords;
numbervar i;
Hope this helps!
Regards,
Vinay -
Missing Sub Totals from web layouts
Hi Gurus
We are on BPS 4.0 and BW 3.5
I have made some changes to a layout (inserted few lines at the top thereby pushing earlier lines below) and it looks good when I display planning data in BPS0 but when I display in weblayout, the sub totals are missing and instead blank lines are being shown. I have regenerated layouts, weblayouts 2-3 times but no help.
Obviously, I am doing something wrong. Could someone point me in right direction?
Thanks
RajeshHi,
SAP doesn't recommends to change the generated template from manual layout. If you want to upload your own template then it has to be generic across all applications in BPS.
If you want to increase the number of lines displayed in layout, it should be added in the bottom of the template or else you can use program( se38) UPP_SET_DEFAULT_DUMMIES
Thanks
Pratyush -
Hi experts,
<br>
<br>
i have the following problem. I've already checked this forum for it and the internet but i can't find a solution. Maybe someone of you can help me or give me a hint.
<br>
<br>
I have a printform with a table in it, i'm able to calculate page wise totals and grandtotal. But i need now a total for groups.
<br>
<br>
For instance table on first page:
<br><br>
Table header. Nr. | Date | Amount | price |
<br>
Table data 1 | 1.1 | 2 | 2.00 |
<br>
1 | 2.1 | 3 | 3.00 |
<br>
2 | 2.1 | 3 | 3.00 |
<br>
2 | 2.1 | 3 | 3.00 |
<br>
3 | 2.1 | 3 | 3.00 |
<br>
3 | 2.1 | 3 | 3.00 |
<br>
3 | 2.1 | 3 | 3.00 |
<br>
Table footer |pagesum|
<br><br>
For instance table on second page:
<br><br>
Table header. Nr. | Date | Amount | price |
<br>
Table data 4 | 1.1 | 2 | 2.00 |
<br>
4 | 2.1 | 3 | 3.00 |
<br>
4 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
Table footer |pagesum|
<br>
Field |grad total|
<br><br>
This is the form like i have it at the moment! I want to achieve the following form.
<br><br>
For instance table on first page:
<br><br>
Table header. Nr. | Date | Amount | price |
<br>
Table data 1 | 1.1 | 2 | 2.00 |
<br>
1 | 2.1 | 3 | 3.00 |
<br>
total |Nr 1total|
<br>
2 | 2.1 | 3 | 3.00 |
<br>
2 | 2.1 | 3 | 3.00 |
<br>
total |Nr 2total|
<br>
3 | 2.1 | 3 | 3.00 |
<br>
3 | 2.1 | 3 | 3.00 |
<br>
3 | 2.1 | 3 | 3.00 |
<br>
total3 |Nr 3total|
<br>
Table footer |pagesum|
<br><br>
For instance table on second page:
<br><br>
Table header. Nr. | Date | Amount | price |
<br>
Table data 4 | 1.1 | 2 | 2.00 |
<br>
4 | 2.1 | 3 | 3.00 |
<br>
4 | 2.1 | 3 | 3.00 |
<br>
total |Nr 4total|
<br>
5 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
5 | 2.1 | 3 | 3.00 |
<br>
total |Nr 5total|
<br>
Table footer |pagesum|
<br>
Field |grad total|
<br><br>
Is this possible in Adobe Interactive Forms?
<br>
<br>
Thanks for help in advanced!!!!Hi,
Try to create a manual running total formula for summing the fields with a condition.
Create a @reset formula and place it report header:
formula:
whileprintingrecords;
numbervar i:=0;
Create a @eval formula and place it in group header A:
formula:
whileprintingrecords;
numbervar i;
if {groupname.field} = 'Labour' or {groupname.field} = 'Expenses' then
i:= i + {summary.field};
Create a @display formula and place it in report footer;
formula:
whileprintingrecords;
numbervar i;
Hope this helps!
Regards,
Vinay -
How to Create Instances in the Transient Root Node and Sub Nodes from Root Node Query Method ?
Hi All,
I am Creating a BOPF BO with 3 Nodes,
Node 1) ROOT -- > contains a query,
using Root Node I have created Search UIBB Configuration in FBI.
In testing -- > when i enter Data in the Search Criteria Fields am able to get the details in to the query method
from Imporing parameter : 'IT_SELECTION_PARAMETERS'.
HERE I am fetching data from a standard table and trying to fill the data in the Node : 'MNR_SEARCH_RESULT'.
How to Append data to the Sub node 'MNR_SEARCH_RESULT' when there is no Node instance created in the ROOT Node ?
For This I have created an instance in the ROOT Node and Using that I tried to create Instance in the Sub Node 'MNR_SEARCH_RESULT'.
Below is my code which i have placed in the Query method ..
DATA : LR_DATA TYPE REF TO ZBO_S_ROOT1.
DATA : LR_SEARCH_RES TYPE REF TO ZBO_S_MNR_SEARCH_RESULT.
DATA : LO_CI_SERVICE_MANAGER TYPE REF TO /BOBF/IF_TRA_SERVICE_MANAGER,
LO_TRANSACTION_MANAGER TYPE REF TO /BOBF/IF_TRA_TRANSACTION_MGR.
LO_CI_SERVICE_MANAGER = /BOBF/CL_TRA_SERV_MGR_FACTORY=>GET_SERVICE_MANAGER( IV_BO_KEY = ZIF_BO_TEST_PO_C=>SC_BO_KEY ).
LO_TRANSACTION_MANAGER = /BOBF/CL_TRA_TRANS_MGR_FACTORY=>GET_TRANSACTION_MANAGER( ).
CREATE DATA LR_DATA.
LR_DATA->KEY = LO_CI_SERVICE_MANAGER->GET_NEW_KEY( ).
LR_DATA->ROOT_KEY = IS_CTX-ROOT_NODE_KEY.
LR_DATA->PIPO_MAT_ID = '100100'.
LR_DATA->PIPO_MAT_DESC = 'MATERIAL'.
LR_DATA->PIPO_SPRAS = 'E'.
LR_DATA->PIPO_MATL_TYPE = 'ZPMI'.
LR_DATA->PIPO_MATL_GROUP = 'ZKK'.
DATA lt_mod TYPE /bobf/t_frw_modification.
DATA lo_change TYPE REF TO /bobf/if_tra_change.
DATA lo_message TYPE REF TO /bobf/if_frw_message.
FIELD-SYMBOLS: <ls_mod> LIKE LINE OF lt_mod.
APPEND INITIAL LINE TO lt_mod ASSIGNING <ls_mod> .
<ls_mod>-node = ZIF_BO_TEST_PO_C=>sc_node-ROOT.
<ls_mod>-change_mode = /bobf/if_frw_c=>sc_modify_create.
<ls_mod>-key = LR_DATA->KEY.
<ls_mod>-data = LR_DATA.
DATA : LT_CHG_FIELDS TYPE /BOBF/T_FRW_NAME.
DATA : LS_CHG_FIELDS LIKE LINE OF LT_CHG_FIELDS.
DATA : LV_KEY TYPE /BOBF/CONF_KEY.
CALL METHOD IO_MODIFY->CREATE
EXPORTING
IV_NODE = ZIF_BO_TEST_PO_C=>sc_node-ROOT
IV_KEY = LR_DATA->KEY
IS_DATA = LR_DATA
IV_ROOT_KEY = IS_CTX-ROOT_NODE_KEY
IMPORTING
EV_KEY = LV_KEY .
CREATE DATA LR_SEARCH_RES.
LR_SEARCH_RES->KEY = LO_CI_SERVICE_MANAGER->GET_NEW_KEY( )..
LR_SEARCH_RES->PARENT_KEY = LV_KEY.
LR_SEARCH_RES->ROOT_KEY = LV_KEY.
LR_SEARCH_RES->MATNR = '123'.
LR_SEARCH_RES->ERSDA = SY-DATUM.
LR_SEARCH_RES->ERNAM = SY-UNAME.
**LR_SEARCH_RES->LAEDA = .
**LR_SEARCH_RES->AENAM = .
**LR_SEARCH_RES->VPSTA = .
*LR_SEARCH_RES->LVORM = .
LR_SEARCH_RES->MTART = 'ZPI'.
LR_SEARCH_RES->MBRSH = 'ZTP' .
LR_SEARCH_RES->MATKL = 'MAT'.
**LR_SEARCH_RES->BISMT = ''
**LR_SEARCH_RES->MEINS =
CALL METHOD io_modify->create
EXPORTING
iv_node = ZIF_BO_TEST_PO_C=>sc_node-MNR_SEARCH_RESULT
is_data = LR_SEARCH_RES
iv_assoc_key = ZIF_BO_TEST_PO_C=>sc_association-root-MNR_SEARCH_RESULT
iv_source_node_key = ZIF_BO_TEST_PO_C=>sc_node-root
iv_source_key = LV_KEY
iv_root_key = LV_KEY.
I am Unable to set data to the Node . I did not get any error message or Dump while executing . when i tried to retrive data I got the details from the node but am unable to view those details in the FBI UI and BOBT UI while testing .
Please provide your valuable Suggestions.
Thanks in Adv.
Thanks ,
Kranthi Kumar M.Hi Kranthi,
For your requirement you need only two nodes. Root Node and Result node. Use the same structure for both.
To create Instance while search.
Create Query method with input type which has the required fields for selection criteria.
Fetch the data and create instance in the root node.
Pass the new instance key as exporting parameter form Query Method.
To Move data from ROOT to Result.
Create a action at root node.
Write a code to create new entries in Result node.
Then configure the Search UIBB and display result in List UIBB. Add button and assign the action MOVE_MAT_2_RESULT.
Create another List uibb to display data from Result node.
Connect the UIBBs using wire schema. SEARCH -> LIST(ROOT) ---> LIST(RESULT).
Give src node association for ROOT to RESULT Configuration.
Regards,
Sunil -
Calculate total from a Union query
Hi
I want to UNION 3 query and need to create a total column. Below My table
ID Date NoofVisit
1 4/21/2014 1
1 4/22/2014 1
1 4/23/2014 1
1 4/24/2014 1
Another query
ID Date NoofVisit
1 4/21/2014 2
1 4/24/2014 1
1 4/26/2014 1
Another query
ID Date NoofVisit
1 4/22/2014 2
1 4/26/2014 1
1 4/28/2014 1
My query is below
SELECT Id, Date, NoofVisit
FROM dbo.vw_MO_All_FirstVisit
UNION
SELECT Id, Date, NoofVisit
FROM vw_MO_All_SecondVisit
UNION
SELECT Id, Date, Noofvisit
FROM vw_MO_All_ThirdVisit
The result is
ID Date NoofVisit
1 4/21/2014 1
1 4/22/2014 1 Its should be 3
1 4/23/2014 1
1 4/24/2014 1 Its should be 2
1 4/26/2014 1 Its should be 2
1 4/28/2014 1
Now what should the query is?
Please help.
Thanks in advanceYou can also get this output using JOIN
SELECT COALESCE(t1.ID,t2.ID,t3.ID) AS ID,
COALESCE(t1.[Date],t2.[Date],t3.[Date]) AS [Date],
COALESCE(t1.NoOfVisit,0) + COALESCE(t2.NoOfVisit,0) + COALESCE(t3.NoOfVisit,0) AS TotalVisits
FROM dbo.vw_MO_All_FirstVisit t1
FULL JOIN dbo.vw_MO_All_SecondVisit t2
ON t2.ID = t1.ID
AND t2.[Date] = t1.[Date]
FULL JOIN dbo.vw_MO_All_ThirdVisit t3
ON t3.ID = t1.ID
AND t3.[Date] = t1.[Date]
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Help needed urgently: Sub-Total from Child Dataset returns 0 value
Hi all,
I REALLY need help on this I can't figure it out. I'm using rtf, bi desktop tool 11.1.5.
My dataset structure is as follows:
G1
Major_Service
Strategy
Period_Actual
Period_Budget
G3
WBS_Name --->=Major_Service
Task_Name ---->=Strategy
Forecast
G3 is the child dataset which I tried to indent right to show the structure but this editor is not catering to that.
I populated a table with Major_Service, Strategy, Period_Actual, Period_Budget, Forecast; group left by Major_Service; Conditional Region (Major_Service!='A' & 'B')
I am able to get the value for all of it correctly row by row, with the condition met, however when I get to subtotal by group, subtotal of Forecast comes as '0.00'.
The code is <?sum (current-group()/FORECAST)?> while the code for others are also the same.
How can I get the output for subtotal for Forecast? Please advise.
Thanks,
Bavani
Edited by: 869112 on Jul 9, 2012 11:25 PMIf forecast is column in group G3 and you are trying to find aggregate values after end of group G3 (and inside group G1) then you will zero values.
e.g.
If you have pseudo code like this, aggregate forecast value will be zero.
<start group G1>
<start group G3>
Some calculations on G3 columns
<end group G3>
Sum on forecast (which is column in group G3)>
<end group G1> -
How to handle goup sub total for each group in oracle query ?
hi,
i want to handle one complex thing in oracle query.
i have a grouping in my oracle query.
i want to do sub total for each group in query and after that i want to subtract one group sub total from previous group subtotal ?
so how can i handle this in oracle query ?
any help is greatly appreciated.
thanks.Hello
Interesting requirement.
I wonder why are you not using these calculation during the display time. If it is acceptable then you can try using the custom formula with the running total combination in crystral report to achieve to get the required results.
Best regards
Ali Hadi -
Dear All,
I need to calculate sub totals then group totals and grand totals.
ex
x y z Val1 val2 val3
x1 y1 z1 10 20 30
x1 y1 z2 10 20 30
x1 y2 z3 10 20 30
Req Format
x y z Val1 val2 val3
x1 y1 z1 10 20 30
x1 y1 z2 10 20 30
y1 sum 20 40 60
x1 y2 z3 10 20 30
x1(sum) 30 60 90
for that one where i need to make changes while in query in data set Or in template
Awaiting for reply
Subbu...Yes. I also wanna know how to do it. Would you pls point out an instruction for us? I read <<Oracle Business Intelligence Publisher B40017>> intensively. But I cann't find out any clue in it yet.
I'm very urgent. Can you tell us how to do it? -
Customised sub-total via UNION query - how to exclude from totals?
Hi,
I have a client requirement that a couple of companies have their own sub-total in a report, a treatment which applies to no other companies in their group.
I have achieved this via a union all, but they also want a total of companies.
Is there anyway to emulate a Grand Total, other than another union query such that the double count is not double counted?
thanks for any ideas.
Robert.only solution which i can think of is to create another union request for the grand total.. this way you wont add up your sub totals twice..
-
Help in the query for sub total.
hi friends.
i have a query display below output.
but i wanted to get sub total of each repeated records,.
Output is like below.
Segment
Units
Total items
CRE
CRE - MUMBAI
3
CTA
CTA - CHENNAI
13
CTA
CTA - DELHI
37
CTA
CTA - HYDERABAD
10
CTA
CTA - KOLKATTA
22
CTA
CTA - MUMBAI
110
Now i need to show like below. if you see the sub total in bold.
Segment
Units
Total items
CRE
CRE - MUMBAI
3
CRE
Sub Total
3
CTA
CTA - CHENNAI
13
CTA
CTA - DELHI
37
CTA
CTA - HYDERABAD
10
CTA
CTA - KOLKATTA
22
CTA
CTA - MUMBAI
110
CTA
Sub Total
192
please help.with
the_data as
(select 'CRE' segment,'CRE - MUMBAI' units,3 total_items from dual union all
select 'CTA','CTA - CHENNAI',13 from dual union all
select 'CTA','CTA - DELHI',37 from dual union all
select 'CTA','CTA - HYDERABAD',10 from dual union all
select 'CTA','CTA - KOLKATTA',22 from dual union all
select 'CTA','CTA - MUMBAI',110 from dual
select segment,
case grouping_id(segment,units) when 0
then units
when 1
then 'Sub total'
else 'Grand total'
end units,
sum(total_items) total_items
from the_data
group by rollup(segment,units)
SEGMENT
UNITS
TOTAL_ITEMS
CRE
CRE - MUMBAI
3
CRE
Sub total
3
CTA
CTA - DELHI
37
CTA
CTA - MUMBAI
110
CTA
CTA - CHENNAI
13
CTA
CTA - KOLKATTA
22
CTA
CTA - HYDERABAD
10
CTA
Sub total
192
Grand total
195
Regards
Etbin -
How to create a sub total and grand total using my query.
How can I create a sub total for each section and grand total for using my query like this. your help is appreciated. I am working with 9g
WITH BidItemsInformation AS
( SELECT DISTINCT q.iplineno "Line Number", q.section "Section Number",
i.item "Item Number",
initcap(i.idescr) "Description" ,
i.iunits "Unit",
q.qty "Quantity" ,q.price "Engineers Unit Price",
(q.price * q.qty) "Engineers Estimate"
FROM letprop l,
proposal p,
propitem q,
bidlet b,
bidtabs c,
itemlist i,
vendor v,
bidders d
WHERE(l.letting = b.letting
And b.letting = c.letting
And p.cspecyr = i.ispecyr)
AND q.prpitem = i.item
AND p.contid = l.lcontid
AND q.contid = p.contid
AND c.vendor = l.avendor
AND l.CALL = c.CALL
AND q.lineflag = c.lineflag
AND q.iplineno = c.iplineno
AND l.letting = d.letting
AND c.letting = l.letting
AND c.CALL = d.CALL
AND v.vendor = d.vendor
-- AND AND l.letstat = 'A'
AND c.lineflag = 'L'
AND l.letting ='&letting'
AND l.CALL = '&call'
), BiddersInformation AS
-- This is where you make your changes for vendor name and vendor number Do not touch the above code
-- It is always the same for any call number and letting date
( SELECT IPLINENO "BLine Number",
MAX(CASE WHEN VENDOR='K020' THEN bidprice ELSE NULL END) "K020:: Unit Price",
MAX(CASE WHEN VENDOR='K020' THEN bidprice ELSE NULL END) K,
MAX(CASE WHEN VENDOR='H438' THEN bidprice ELSE NULL END) "H438:: Unit Price",
MAX(CASE WHEN VENDOR='H438' THEN bidprice ELSE NULL END) H,
MAX(CASE WHEN VENDOR='U010' THEN bidprice ELSE NULL END) "U010:: Unit Price",
MAX(CASE WHEN VENDOR='U010' THEN bidprice ELSE NULL END) U,
MAX(CASE WHEN VENDOR='G110' THEN bidprice ELSE NULL END) "G110:: Unit Price",
MAX(CASE WHEN VENDOR='G110' THEN bidprice ELSE NULL END) G,
MAX(CASE WHEN VENDOR='H530' THEN bidprice ELSE NULL END) "H530:: Unit Price",
MAX(CASE WHEN VENDOR='H530' THEN bidprice ELSE NULL END) H1
FROM BIDTABS
WHERE LETTING='&letting'
AND CALL='&call'
AND BIDPRICE <> 0
GROUP BY IPLINENO
SELECT BidItemsInformation."Line Number",
BidItemsInformation."Section Number",
BidItemsInformation."Item Number",
BidItemsInformation."Description",
BidItemsInformation."Unit",
BidItemsInformation."Quantity",
BidItemsInformation."Engineers Unit Price",
BidItemsInformation."Engineers Estimate",
BiddersInformation."K020:: Unit Price",
(BidItemsInformation."Quantity" * K) "KGM CONTRACTORS INC",
BiddersInformation."H438:: Unit Price",
(BidItemsInformation."Quantity" * H) "HOFFMAN CONSTRUCTION COMPAN",
BiddersInformation."U010:: Unit Price",
(BidItemsInformation."Quantity" * U) "ULLAND BROTHERS INC",
BiddersInformation."G110:: Unit Price",
(BidItemsInformation."Quantity" * G) "GLADEN CONSTRUCTION INC",
BiddersInformation."H530:: Unit Price",
(BidItemsInformation."Quantity" * H1) "HOOVER CONSTRUCTION CO"
FROM BidItemsInformation,BiddersInformation
WHERE BidItemsInformation."Line Number" = BiddersInformation."BLine Number";
Line Number Section Number Item Number Description Unit Quantity Engineers Unit Price Engineers Estimate K020:: Unit Price
0010 0001 2011601/00003 Construction Surveying LS 1 143,000 143,000 75,000 75,000 67,080 67,080
0013 0001 2013601/00010 Survey Equipment LS 1 25,000 25,000 25,000 25,000 30,000 30,000
0020 0001 2015601/00030 Blast Monitor/Survey LS 1 50,000 50,000 30,000 30,000 35,000 35,000
0030 0001 2021501/00010 Mobilization LS 1 382,250 382,250 809,000 809,000 704,000 704,000
0040 0001 2021602/00010 Well Survey EACH 60 500 30,000 2,150 129,000 1,600 96,000
0050 0001 2031501/00040 Field Office Type D EACH 1 6,367 6,367 4,000 4,000 25,000 25,000
sub total:
1610 0002 2401501/01143 Structural Concrete (1a43) C Y 46 350 16,100 408 18,768 400 18,400
1620 0002 2401501/01362 Structural Concrete (1c62) C Y 68 200 13,600 204 13,872 200 13,600
1630 0002 2401501/03643 Structural Concrete (3y43) C Y 60 600 36,000 592 35,520 580 34,800
1640 0002 2401512/03633 Bridge Slab Concrete (3y33) S F 1,876 24 45,024 28 51,778 27 50,652
1650 0002 2401521/00030 Structure Excavation Class R C Y 17 125 2,125 1,000 17,000 500 8,500
1660 0002 2401541/00010 Reinforcement Bars LB 2,490 2 3,735 1 3,312 1 3,237
1670 0002 2401541/00011 Reinforcement Bars (Epoxy Coated) LB 12,380 2 18,570 1 17,703 1 17,332
1680 0002 2401601/00010 Structure Excavation LS 1 2,500 2,500 2,000 2,000 5,000 5,000
1690 0002 2402583/00020 Ornamental Metal Railing Type Special L F 284 150 42,600 194 55,096 190 53,960
sub total
1820 0003 2401513/00346 Type Curb Railing Concrete (3y46) L F 135 25 3,375 16 2,093 15 2,025
1830 0003 2401513/07447 Type Mod P-4 (Tl-4) Railing Conc (3y46) L F 302 85 25,670 72 21,593 70 21,140
1840 0003 2401541/00010 Reinforcement Bars LB 14,780 1 18,475 1 13,598 1 13,302
1850 0003 2401541/00011 Reinforcement Bars (Epoxy Coated) LB 76,720 1 103,572 1 85,926 1 84,392
1860 0003 2401601/00010 Structure Excavation LS 1 10,000 10,000 116,000 116,000 115,000 115,000
1870 0003 2402583/00020 Ornamental Metal Railing Type Special L F 132 150 19,800 184 24,288 180 23,760
sub total
totalYou can accomplish that using decode with the grouping function. It returns 1 when that column passed as argument was grouped (or is in some total) and 0 otherwise.
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> with t as
2 (select 'New York' city, 'US' country, 1 num from dual
3 union all select 'Los Angeles' city, 'US' country, 2 num from dual
4 union all select 'London' city, 'GB' country, 2 num from dual
5 union all select 'London' city, 'GB' country, 2 num from dual
6 union all select 'London' city, 'GB' country, 7 num from dual)
7 select decode(grouping(country), 0, country, 'GRAND TOTAL') country,
8 decode(grouping(city), 0, city, decode(grouping(country), 0, 'SUBTOTAL')) city,
9 sum(num) num_total
10 from t
11 group by rollup(country, city)
12 /
COUNTRY CITY NUM_TOTAL
GB London 11
GB SUBTOTAL 11
US New York 1
US Los Angeles 2
US SUBTOTAL 3
GRAND TOTAL 14
6 linhas selecionadas.
SQL> -
Force the Summary Sub totals on same page as the Repeating Group
Hello folks,
I have a Group by Left Report where I am showing Patients and the Visits that they have taken for each Department.
I am then doing a Sub Total of the number of Visits the Patient has taken. I would like to make sure that the sub total shows
up on the same page as the data in the Repeating Group. I tried using an Anchor but the Report does not like it.
It gives an Error: REP 1213 - Field references column at a frequency below its group when I anchor from Repeating frame to the sub total footer
and REP 1814 Report cannot be formatted. Object 'Horizontally' can never fit within 'M_1' when I try to anchor the other way.
My goal is to show the Sub Totals (Total) on the same page as the Patient and not go to the next page. I have enclosed the single dashed line and the Total (Label and field) in a Frame.
Output of Report:
Patient ID Patient Name Department Visit
======================================================================
1001 Mary Poppins Department 001 3
Department 002 4
Department 003 1
Total 8
1002 Peter Pan Department 001 2
Department 002 1
Department 003 2
Total 5
-----------------------------Thanks in advance!Pls set the property(page protect of the frame containing both sub total and patient details) to yes.
-
Dear Experts,
This is Query related to UDT Table named @PPC I want to do Sub Total in Plan Qty Column and Selection Criteria Finished Size Column i.e u_0024 (But i defined these field Type is Text so how should i convert ( In varchar or other form) and Plan Qty Column u_9999 Sub Total (through Union but i dont know how to do please help me out.
Query Find
SELECT CONVERT (FLOAT,CODE)'SR',u_0001,u_0002,t1.codebars ,u_0003,u_0004,u_0005,
u_0006,u_0007,u_0008,u_0009,u_0010,u_9999' Plan Qty' ,u_0011,u_0012,u_0013,u_0014,u_0015,
u_0016,u_0017,u_0018,u_0019,u_0020,u_0021,u_0022,u_0023,u_0024 'Finished Size' ,u_0025,
u_0026,u_0027,u_0028,u_0029,u_0030,u_mc,u_prodqty
FROM [dbo].[@PPC] t0 inner join oitm t1 on
t0.u_0003 = t1.itemcode
where ( t0.u_0008 = '[%1]' or '[%1]'='')
and ( t1.codebars = '[%2]' or '[%2]'='')
and ( t0.u_0009 = '[%3]' or '[%3]'='')
and ( t0.u_0014 = '[%4]' or '[%4]'='')
and ( t0.u_0007 = '[%5]' or '[%5]'='')
and ( t0.u_0027 = '[%6]' or '[%6]'='')
and ( t0.u_0011 = '[%7]' or '[%7]'='')
ORDER BY SRResolve by me
-
SQL query to retrieve totals from "supporting Details"
We've had a strange issue where the totals from the supporting details aren't adding up to the value submitted in essbase.
In effect our RDMS is out of sync with Planning.
In order to remedy this, I'm trying to build a SQL query to retrieve the value of the supporting details.
Here is my Sql statement so far :
SELECT
HO1.OBJECT_NAME SCENARIO,
HO2.OBJECT_NAME ACCOUNT,
HO3.OBJECT_NAME ENTITY,
HO4.OBJECT_NAME Month,
HO5.OBJECT_NAME Version,
HO6.OBJECT_NAME Currency,
HO7.OBJECT_NAME Year,
HO8.OBJECT_NAME Project,
HO10.OBJECT_NAME CC,
HO12.OBJECT_NAME Grplcl,
HO13.OBJECT_NAME Product,
HO15.OBJECT_NAME SalesRegion,
HO16.OBJECT_NAME ContractAnalysis,
HO17.OBJECT_NAME IC,
SUM(NVL(HCDI.VALUE,0)) AMOUNT
FROM hsp_column_detail HCD,
hsp_column_detail_ITEM HCDI,
HSP_OBJECT HO1,
HSP_OBJECT HO2,
HSP_OBJECT HO3,
HSP_OBJECT HO4,
HSP_OBJECT HO5,
HSP_OBJECT HO6,
HSP_OBJECT HO7,
HSP_OBJECT HO8,
HSP_OBJECT HO10,
HSP_OBJECT HO12,
HSP_OBJECT HO13,
HSP_OBJECT HO15,
HSP_OBJECT HO16,
HSP_OBJECT HO17
WHERE hcd.detail_id = hcdi.detail_id
AND hcd.dim1 = ho1.object_id
AND hcd.dim2 = ho2.object_id
AND hcd.dim3 = ho3.object_id
AND hcd.dim4 = ho4.object_id
AND hcd.dim5 = ho5.object_id
AND hcd.dim6 = ho6.object_id
AND hcd.dim7 = ho7.object_id
AND hcd.dim8 = ho8.object_id
AND hcd.dim10 = ho10.object_id
AND hcd.dim12 = ho12.object_id
AND hcd.dim13 = ho13.object_id
AND hcd.dim15 = ho15.object_id
AND hcd.dim16 = ho16.object_id
AND hcd.dim17 = ho17.object_id
and hcdi.generation = 0
GROUP BY HO1.OBJECT_NAME, HO2.OBJECT_NAME, HO3.OBJECT_NAME, HO4.OBJECT_NAME,
HO5.OBJECT_NAME,
HO6.OBJECT_NAME,
HO7.OBJECT_NAME,
HO8.OBJECT_NAME,
HO10.OBJECT_NAME,
HO12.OBJECT_NAME,
HO13.OBJECT_NAME,
HO15.OBJECT_NAME,
HO16.OBJECT_NAME,
HO17.OBJECT_NAME
ORDER BY HO1.OBJECT_NAME, HO3.OBJECT_NAME, HO2.OBJECT_NAMEThis query works using PL SQL and has been used on Oracle 9.2.3.
Cheers,
Jeremie
Here is the Query:
set serveroutput on;
set serveroutput on size 1000000;
--set buffer_size 10000000;
--set line_size 2000;
--DBMS_OUTPUT.size = 2000000;
DECLARE
CURSOR BUDGET_HEADERS_CU IS
SELECT
hcd.detail_id,
HO1.OBJECT_NAME SCENARIO,
HO2.OBJECT_NAME ACCOUNT,
HO3.OBJECT_NAME ENTITY,
HO4.OBJECT_NAME Month,
HO5.OBJECT_NAME Version,
HO6.OBJECT_NAME Currency,
HO7.OBJECT_NAME Year,
HO8.OBJECT_NAME Project,
HO10.OBJECT_NAME CC,
HO12.OBJECT_NAME Grplcl,
HO13.OBJECT_NAME Product,
HO15.OBJECT_NAME SalesRegion,
HO16.OBJECT_NAME ContractAnalysis,
HO17.OBJECT_NAME IC,
hcd.dim1 SCENARIO_id,
hcd.dim2 ACCOUNT_id,
hcd.dim3 ENTITY_id,
hcd.dim4 Month_id,
hcd.dim5 Version_id,
hcd.dim6 Currency_ID,
hcd.dim7 Year_ID,
hcd.dim8 Project_ID,
hcd.dim10 CC_ID,
hcd.dim12 Grplcl_ID,
hcd.dim13 Product_ID,
hcd.dim15 SalesRegion_ID,
hcd.dim16 ContractAnalysis_ID,
hcd.dim17 IC_ID
FROM hsp_column_detail HCD, /*hsp_column_detail_item HCDi,*/
HSP_OBJECT HO1,
HSP_OBJECT HO2,
HSP_OBJECT HO3,
HSP_OBJECT HO4,
HSP_OBJECT HO5,
HSP_OBJECT HO6,
HSP_OBJECT HO7,
HSP_OBJECT HO8,
HSP_OBJECT HO10,
HSP_OBJECT HO12,
HSP_OBJECT HO13,
HSP_OBJECT HO15,
HSP_OBJECT HO16,
HSP_OBJECT HO17
WHERE /*hcd.detail_id = hcdi.detail_id
AND*/ hcd.dim1 = ho1.object_id
AND hcd.dim2 = ho2.object_id
AND hcd.dim3 = ho3.object_id
AND hcd.dim4 = ho4.object_id
AND hcd.dim5 = ho5.object_id
AND hcd.dim6 = ho6.object_id
AND hcd.dim7 = ho7.object_id
AND hcd.dim8 = ho8.object_id
AND hcd.dim10 = ho10.object_id
AND hcd.dim12 = ho12.object_id
AND hcd.dim13 = ho13.object_id
AND hcd.dim15 = ho15.object_id
AND hcd.dim16 = ho16.object_id
AND hcd.dim17 = ho17.object_id
and HO5.OBJECT_NAME = 'Working'
--and hcdi.generation != 0
--and hcdi.label like 'JRTEST-%'
--and hcd.detail_id = 253102
/*GROUP BY HCD.Dim1, HCD.Dim2, HCD.Dim3, HCD.Dim4,
HCD.Dim5,
HCD.Dim6,
HCD.Dim7,
HCD.Dim8,
HCD.Dim10,
HCD.Dim12,
HCD.Dim13,
HCD.Dim15,
HCD.Dim16,
HCD.Dim17*/;
CURSOR BUDGET_DETAILS_CU(
/*scenario_p in varchar2,
account_p in varchar2,
entity_p in varchar2,
month_p in varchar2,
version_p in varchar2,
currency_p in varchar2,
year_p in varchar2,
project_p in varchar2,
cc_p in varchar2,
grplcl_p in varchar2,
product_p in varchar2,
salesregion_p in varchar2,
contractanalysis_p in varchar2,
ic_p in varchar2*/
detail_id_p in number
IS
SELECT
/* HO1.OBJECT_NAME SCENARIO,
HO2.OBJECT_NAME ACCOUNT,
HO3.OBJECT_NAME ENTITY,
HO4.OBJECT_NAME Month,
HO5.OBJECT_NAME Version,
HO6.OBJECT_NAME Currency,
HO7.OBJECT_NAME Year,
HO8.OBJECT_NAME Project,
HO10.OBJECT_NAME CC,
HO12.OBJECT_NAME Grplcl,
HO13.OBJECT_NAME Product,
HO15.OBJECT_NAME SalesRegion,
HO16.OBJECT_NAME ContractAnalysis,
HO17.OBJECT_NAME IC, */
label,
NVL(HCDI.VALUE,0) AMOUNT,
HCDI.Position,
HCDI.operator,
HCDI.generation
FROM /*hsp_column_detail HCD,*/
hsp_column_detail_ITEM HCDI
/* HSP_OBJECT HO1,
HSP_OBJECT HO2,
HSP_OBJECT HO3,
HSP_OBJECT HO4,
HSP_OBJECT HO5,
HSP_OBJECT HO6,
HSP_OBJECT HO7,
HSP_OBJECT HO8,
HSP_OBJECT HO10,
HSP_OBJECT HO12,
HSP_OBJECT HO13,
HSP_OBJECT HO15,
HSP_OBJECT HO16,
HSP_OBJECT HO17*/
--WHERE hcd.detail_id = hcdi.detail_id
WHERE hcdi.detail_id = detail_id_p
/*AND hcd.dim1 = ho1.object_id
AND hcd.dim2 = ho2.object_id
AND hcd.dim3 = ho3.object_id
AND hcd.dim4 = ho4.object_id
AND hcd.dim5 = ho5.object_id
AND hcd.dim6 = ho6.object_id
AND hcd.dim7 = ho7.object_id
AND hcd.dim8 = ho8.object_id
AND hcd.dim10 = ho10.object_id
AND hcd.dim12 = ho12.object_id
AND hcd.dim13 = ho13.object_id
AND hcd.dim15 = ho15.object_id
AND hcd.dim16 = ho16.object_id
AND hcd.dim17 = ho17.object_id*/
--and hcdi.generation != 0
--and label like 'JRTEST-%'
/*AND HCD.Dim1 = scenario_p
AND HCD.Dim2 = account_p
AND HCD.Dim3 = entity_p
AND HCD.Dim4 = month_p
AND HCD.Dim5 = version_p
AND HCD.Dim6 = currency_p
AND HCD.Dim7 = year_p
AND HCD.Dim8 = project_p
AND HCD.Dim10 = cc_p
AND HCD.Dim12 = grplcl_p
AND HCD.Dim13 = product_p
AND HCD.Dim15 = salesregion_p
AND HCD.Dim16 = contractanalysis_p
AND HCD.Dim17 = ic_p*/
ORDER BY hcdi.position;
-- Variable Declaration
running_total_ln number :=0;
prev_running_total_ln number :=0;
add_amount number :=0;
multiply_amount number :=1;
prev_generation number :=0;
prev_add_amount number :=0;
prev_multiply_amount number :=1;
running_total_gen0 number :=0;
running_gen0_op number :=0;
running_total_gen1 number :=0;
running_gen1_op number :=0;
running_total_gen2 number :=0;
running_gen2_op number :=0;
running_total_gen3 number :=0;
running_gen3_op number :=0;
running_total_gen4 number :=0;
running_gen4_op number :=0;
running_total_gen5 number :=0;
running_gen5_op number :=0;
output_file utl_file.file_type;
-- Begin PL/SQL processing
BEGIN
--DBMS_OUTPUT.
DBMS_OUTPUT.ENABLE(1000000);
DBMS_OUTPUT.PUT_LINE('Begin Processing');
output_file := utl_file.fopen ('C:\temp', 'test.txt', 'W');
-- Begin Header For Loop
FOR BUDGET_HEADERS_CV IN BUDGET_HEADERS_CU
LOOP
--Reset Running Totals
running_total_ln:=0;
prev_running_total_ln:=0;
add_amount:=0;
multiply_amount:=1;
prev_generation:=0;
prev_add_amount:=0;
prev_multiply_amount:=1;
running_total_gen0:=0;
running_gen0_op:=0;
running_total_gen1:=0;
running_gen1_op:=0;
running_total_gen2:=0;
running_gen2_op:=0;
running_total_gen3:=0;
running_gen3_op:=0;
running_total_gen4:=0;
running_gen4_op:=0;
running_total_gen5:=0;
running_gen5_op:=0;
-- Begin Detail For Loop
FOR BUDGET_DETAILS_CV IN BUDGET_DETAILS_CU(
BUDGET_HEADERS_CV.Detail_ID
/*BUDGET_HEADERS_CV.SCENARIO_ID,
BUDGET_HEADERS_CV.ACCOUNT_ID,
BUDGET_HEADERS_CV.ENTITY_ID,
BUDGET_HEADERS_CV.Month_ID,
BUDGET_HEADERS_CV.Version_ID,
BUDGET_HEADERS_CV.Currency_ID,
BUDGET_HEADERS_CV.Year_ID,
BUDGET_HEADERS_CV.Project_ID,
BUDGET_HEADERS_CV.CC_ID,
BUDGET_HEADERS_CV.Grplcl_ID,
BUDGET_HEADERS_CV.Product_ID,
BUDGET_HEADERS_CV.SalesRegion_ID,
BUDGET_HEADERS_CV.ContractAnalysis_ID,
BUDGET_HEADERS_CV.IC_ID*/
LOOP
-- Null;
add_amount :=0;
multiply_amount :=1;
IF BUDGET_DETAILS_CV.OPERATOR = 1 THEN
add_amount := BUDGET_DETAILS_CV.Amount;
End if;
IF BUDGET_DETAILS_CV.OPERATOR = 2 THEN
add_amount := BUDGET_DETAILS_CV.Amount * -1;
End if;
IF BUDGET_DETAILS_CV.OPERATOR = 3 THEN
multiply_amount := BUDGET_DETAILS_CV.Amount;
End if;
IF BUDGET_DETAILS_CV.OPERATOR = 4 THEN
multiply_amount := 1/BUDGET_DETAILS_CV.Amount;
End if;
IF BUDGET_DETAILS_CV.Position = 0 then
running_total_gen0 := add_amount*multiply_amount;-- we are dealing with the first line
Else
if BUDGET_DETAILS_CV.GENERATION = prev_generation then
-- run whatever total we are on up
if BUDGET_DETAILS_CV.GENERATION = 0 then
running_total_gen0 := (running_total_gen0 + add_amount)*multiply_amount;
end if;
if BUDGET_DETAILS_CV.GENERATION = 1 then
running_total_gen1 := (running_total_gen1 + add_amount)*multiply_amount;
end if;
if BUDGET_DETAILS_CV.GENERATION = 2 then
running_total_gen2 := (running_total_gen2 + add_amount)*multiply_amount;
end if;
if BUDGET_DETAILS_CV.GENERATION = 3 then
running_total_gen3 := (running_total_gen3 + add_amount)*multiply_amount;
end if;
end if;
if BUDGET_DETAILS_CV.GENERATION = prev_generation +1 then
-- we are going up a generation
-- (we cannot go up to gen0
if BUDGET_DETAILS_CV.GENERATION = 1 then
running_total_gen1:=0;-- reset gen1 counter
running_gen0_op:=BUDGET_DETAILS_CV.OPERATOR; -- Store the sign for later operation
running_total_gen0 := running_total_gen0/prev_multiply_amount - prev_add_amount; -- Remove parent from Gen 0 total
running_total_gen1 := (running_total_gen1 + add_amount)*multiply_amount;
end if;
if BUDGET_DETAILS_CV.GENERATION = 2 then
running_total_gen2:=0;-- reset gen1 counter
running_gen1_op:=BUDGET_DETAILS_CV.OPERATOR; -- Store the sign for later operation
running_total_gen1 := running_total_gen1/prev_multiply_amount - prev_add_amount; -- Remove parent from Gen 1 total
running_total_gen2 := (running_total_gen2 + add_amount)*multiply_amount;
end if;
if BUDGET_DETAILS_CV.GENERATION = 3 then
running_total_gen3:=0;-- reset gen1 counter
running_gen2_op:=BUDGET_DETAILS_CV.OPERATOR; -- Store the sign for later operation
running_total_gen2 := running_total_gen2/prev_multiply_amount - prev_add_amount; -- Remove parent from Gen 2 total
running_total_gen3 := (running_total_gen3 + add_amount)*multiply_amount;
end if;
end if;
if BUDGET_DETAILS_CV.GENERATION = prev_generation - 1 then
-- we are Down a generation
if BUDGET_DETAILS_CV.GENERATION = 0 then
--we need to "add" back the previous gen 1 parent
IF running_gen0_op = 1 THEN
running_total_gen0 := running_total_gen0 + running_total_gen1;
End if;
IF running_gen0_op = 2 THEN
running_total_gen0 := running_total_gen0 - running_total_gen1;
End if;
IF running_gen0_op = 3 THEN
running_total_gen0 := running_total_gen0 * running_total_gen1;
End if;
IF running_gen0_op = 4 THEN
running_total_gen0 := running_total_gen0 / running_total_gen1;
End if;
-- we need to add the current member to the gen0
running_total_gen0 := (running_total_gen0 + add_amount)*multiply_amount;
END IF;
if BUDGET_DETAILS_CV.GENERATION = 1 then
--we need to "add" back the previous gen 2 parent
IF running_gen1_op = 1 THEN
running_total_gen1 := running_total_gen1 + running_total_gen2;
End if;
IF running_gen1_op = 2 THEN
running_total_gen1 := running_total_gen1 - running_total_gen2;
End if;
IF running_gen1_op = 3 THEN
running_total_gen1 := running_total_gen1 * running_total_gen2;
End if;
IF running_gen1_op = 4 THEN
running_total_gen1 := running_total_gen1 / running_total_gen2;
End if;
-- we need to add the current member to the gen1
running_total_gen1 := (running_total_gen1 + add_amount)*multiply_amount;
end if;
if BUDGET_DETAILS_CV.GENERATION = 2 then
--we need to "add" back the previous gen 3 parent
IF running_gen1_op = 1 THEN
running_total_gen2 := running_total_gen2 + running_total_gen3;
End if;
IF running_gen1_op = 2 THEN
running_total_gen2 := running_total_gen2 - running_total_gen3;
End if;
IF running_gen1_op = 3 THEN
running_total_gen2 := running_total_gen2 * running_total_gen3;
End if;
IF running_gen1_op = 4 THEN
running_total_gen2 := running_total_gen2 / running_total_gen3;
End if;
-- we need to add the current member to the gen2
running_total_gen2 := (running_total_gen2 + add_amount)*multiply_amount;
end if;
end if;
if BUDGET_DETAILS_CV.GENERATION = prev_generation - 2 then
-- we are Down 2 generations
if BUDGET_DETAILS_CV.GENERATION = 0 then
--we need to "add" back the previous gen 2 parent
IF running_gen1_op = 1 THEN
running_total_gen1 := running_total_gen1 + running_total_gen2;
End if;
IF running_gen1_op = 2 THEN
running_total_gen1 := running_total_gen1 - running_total_gen2;
End if;
IF running_gen1_op = 3 THEN
running_total_gen1 := running_total_gen1 * running_total_gen2;
End if;
IF running_gen1_op = 4 THEN
running_total_gen1 := running_total_gen1 / running_total_gen2;
End if;
--we need to "add" back the previous gen 1 parent
IF running_gen0_op = 1 THEN
running_total_gen0 := running_total_gen0 + running_total_gen1;
End if;
IF running_gen0_op = 2 THEN
running_total_gen0 := running_total_gen0 - running_total_gen1;
End if;
IF running_gen0_op = 3 THEN
running_total_gen0 := running_total_gen0 * running_total_gen1;
End if;
IF running_gen0_op = 4 THEN
running_total_gen0 := running_total_gen0 / running_total_gen1;
End if;
-- we need to add the current member to the gen0
running_total_gen0 := (running_total_gen0 + add_amount)*multiply_amount;
END IF;
if BUDGET_DETAILS_CV.GENERATION = 1 then
--we need to "add" back the previous gen 3 parent
IF running_gen1_op = 1 THEN
running_total_gen2 := running_total_gen2 + running_total_gen3;
End if;
IF running_gen1_op = 2 THEN
running_total_gen2 := running_total_gen2 - running_total_gen3;
End if;
IF running_gen1_op = 3 THEN
running_total_gen2 := running_total_gen2 * running_total_gen3;
End if;
IF running_gen1_op = 4 THEN
running_total_gen2 := running_total_gen2 / running_total_gen3;
End if;
--we need to "add" back the previous gen 2 parent
IF running_gen1_op = 1 THEN
running_total_gen1 := running_total_gen1 + running_total_gen2;
End if;
IF running_gen1_op = 2 THEN
running_total_gen1 := running_total_gen1 - running_total_gen2;
End if;
IF running_gen1_op = 3 THEN
running_total_gen1 := running_total_gen1 * running_total_gen2;
End if;
IF running_gen1_op = 4 THEN
running_total_gen1 := running_total_gen1 / running_total_gen2;
End if;
-- we need to add the current member to the gen1
running_total_gen1 := (running_total_gen1 + add_amount)*multiply_amount;
END IF;
if BUDGET_DETAILS_CV.GENERATION = prev_generation - 3 then
-- we are Down 3 generations
if BUDGET_DETAILS_CV.GENERATION = 0 then
--we need to "add" back the previous gen 3 parent
IF running_gen1_op = 1 THEN
running_total_gen2 := running_total_gen2 + running_total_gen3;
End if;
IF running_gen1_op = 2 THEN
running_total_gen2 := running_total_gen2 - running_total_gen3;
End if;
IF running_gen1_op = 3 THEN
running_total_gen2 := running_total_gen2 * running_total_gen3;
End if;
IF running_gen1_op = 4 THEN
running_total_gen2 := running_total_gen2 / running_total_gen3;
End if;
--we need to "add" back the previous gen 2 parent
IF running_gen1_op = 1 THEN
running_total_gen1 := running_total_gen1 + running_total_gen2;
End if;
IF running_gen1_op = 2 THEN
running_total_gen1 := running_total_gen1 - running_total_gen2;
End if;
IF running_gen1_op = 3 THEN
running_total_gen1 := running_total_gen1 * running_total_gen2;
End if;
IF running_gen1_op = 4 THEN
running_total_gen1 := running_total_gen1 / running_total_gen2;
End if;
--we need to "add" back the previous gen 1 parent
IF running_gen0_op = 1 THEN
running_total_gen0 := running_total_gen0 + running_total_gen1;
End if;
IF running_gen0_op = 2 THEN
running_total_gen0 := running_total_gen0 - running_total_gen1;
End if;
IF running_gen0_op = 3 THEN
running_total_gen0 := running_total_gen0 * running_total_gen1;
End if;
IF running_gen0_op = 4 THEN
running_total_gen0 := running_total_gen0 / running_total_gen1;
End if;
-- we need to add the current member to the gen0
running_total_gen0 := (running_total_gen0 + add_amount)*multiply_amount;
END IF;
end if;
END IF;
End IF;
END LOOP; -- End of Detail Loop
--DBMS_OUTPUT.PUT_LINE(BUDGET_HEADERS_CV.SCENARIO||';'||BUDGET_HEADERS_CV.ACCOUNT||';'||BUDGET_HEADERS_CV.ENTITY||';'||BUDGET_HEADERS_CV.Month||';'||BUDGET_HEADERS_CV.Version||';'||BUDGET_HEADERS_CV.Currency||';'||BUDGET_HEADERS_CV.Year||';'||BUDGET_HEADERS_CV.Project||';'||BUDGET_HEADERS_CV.CC||';'||BUDGET_HEADERS_CV.Grplcl||';'||BUDGET_HEADERS_CV.Product||';'||BUDGET_HEADERS_CV.SalesRegion||';'||BUDGET_HEADERS_CV.ContractAnalysis||';'||BUDGET_HEADERS_CV.IC||';'||running_total_gen0);
utl_file.put_line(output_file,BUDGET_HEADERS_CV.SCENARIO||';'||BUDGET_HEADERS_CV.ACCOUNT||';'||BUDGET_HEADERS_CV.ENTITY||';'||BUDGET_HEADERS_CV.Month||';'||BUDGET_HEADERS_CV.Version||';'||BUDGET_HEADERS_CV.Currency||';'||BUDGET_HEADERS_CV.Year||';'||BUDGET_HEADERS_CV.Project||';'||BUDGET_HEADERS_CV.CC||';'||BUDGET_HEADERS_CV.Grplcl||';'||BUDGET_HEADERS_CV.Product||';'||BUDGET_HEADERS_CV.SalesRegion||';'||BUDGET_HEADERS_CV.ContractAnalysis||';'||BUDGET_HEADERS_CV.IC||';'||running_total_gen0);
/*BUDGET_HEADERS_CV.SCENARIO, BUDGET_HEADERS_CV.ACCOUNT, BUDGET_HEADERS_CV.ENTITY, BUDGET_HEADERS_CV.Month, BUDGET_HEADERS_CV.Version,BUDGET_HEADERS_CV.Currency, BUDGET_HEADERS_CV.Year, BUDGET_HEADERS_CV.Project, BUDGET_HEADERS_CV.CC, BUDGET_HEADERS_CV.Grplcl, BUDGET_HEADERS_CV.Product, BUDGET_HEADERS_CV.SalesRegion, BUDGET_HEADERS_CV.ContractAnalysis, BUDGET_HEADERS_CV.IC */
END LOOP; -- End of Header Loop
--DBMS_OUTPUT.PUT_LINE('Total');
-- DBMS_OUTPUT.PUT_LINE('End Processing');
utl_file.fclose(output_file);
END;
Edited by: JeremieR on Apr 18, 2011 5:02 AM
Maybe you are looking for
-
I work in schools and would like to know if a school opens an iTunes account to purchase apps, how many iPads can that app be loaded onto legally?
-
G5 Starts Up Fine But Doesn't Start Monitor Consistently! I'm stumped!
Hello all. I just purchased a new Mac Pro. My G5 has been problematic for a number of months now even under Leopard. I replaced the internal battery, have done PMU and zapped PRAM and nothing solved my problem. The problem has been: It takes me at le
-
Respected Gurus, This time I am back with different story, a part issue and a part way out!! In case of group conditions, the scaling price is always taken on the sum/cumulative value of the two conditions, after the purchase order is saved. I figur
-
Get "version error" when try to register 7940 phone
When I try to register a cisco 7940 iphone I get the "version error" - from research it said to double check to make sure you have the right model phone. I do have the correct phone type specified but still gets this error When an attempt i
-
I have a nearly new ibookG4 running latest version of Airport Extreme through and with year old Emac G4 acting as its mother ship, and would like to establish best security when using (transmitting) the ibook, during which I consider myself vulnerabl