我想计算我在级别突破页脚组中获得的总数。
例子:
Item A1 - 10
Item A2 - 20
Item A3 - 30
Total = 60
Item B1 - 10
Item B2 - 20
Total = 30
Grand Total 90
我应该怎么办?
您可以使用汇总。希望有帮助。
编辑:没有认识到这个问题与 JDEdwards 有关,所以这就是在 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)
我假设您有超过 2 个排序列。让我们假设它们是 MCU(Business Unit), DOCO(Order No),LITM(Item Number)
您将通过在 DOCO 上放置一个级别中断页脚并在 BC LITM 上使用聚合函数 (sumof) 来获得小计(该项目需要显示在父部分中)
要获得总计,您可以做 2 件事:
a:创建一个全局变量并将小计存储在其中并不断将其添加到自身。(最后显示为总计)
b:在现有的level-break footer中添加一个level-break footer(在MCU上)并在BC LITM上执行sumof
我希望这能解决你的问题:)