I want to calculate a grand total of those total I get on level break footer group.
Example:
Item A1 - 10
Item A2 - 20
Item A3 - 30
Total = 60
Item B1 - 10
Item B2 - 20
Total = 30
Grand Total 90
What should I do?
I want to calculate a grand total of those total I get on level break footer group.
Example:
Item A1 - 10
Item A2 - 20
Item A3 - 30
Total = 60
Item B1 - 10
Item B2 - 20
Total = 30
Grand Total 90
What should I do?
You can use rollup. Hope that helps.
EDIT: Did not recognized that the question is related to JDEdwards so this is how it would be done in Oralce SQL.
with
items as (
select 'A' as grp, '1' as item, 10 as val from dual
union
select 'A' as grp, '2' as item, 20 as val from dual
union
select 'A' as grp, '3' as item, 30 as val from dual
union
select 'B' as grp, '1' as item, 10 as val from dual
union
select 'B' as grp, '2' as item, 20 as val from dual
)
select case
when grouping(grp) = 1 then 'Grand Total ' || grp || sum(val)
when grouping(item) = 1 then 'Total ' || grp || ' = ' || sum(val)
else 'Item ' || grp || item || ' - ' || max(val)
end
from items
group by rollup (grp, item)
I assume you have more than 2 sort columns. Let us assume them to be MCU(Business Unit),DOCO(Order No),LITM(Item Number)
You will get your subtotal by putting a level-break footer on DOCO and using the aggregate function (sumof) on BC LITM (The item needs to be displayed in the parent section)
To get Grand Total, you can do 2 things:
a: Make a global variable and store the subtotal in it and keep adding it to itself. (Display it at the end as Grand Total)
b: Add a level-break footer (on MCU) inside the existing level-break footer and perform sumof on BC LITM
I hope this solves your problem :)