I'm trying to debug someone elses ORACLE 9i SQL for a CR-XI report - and my PL/SQL needs some dusting off (it's been a while).
The SQL below is giving bad results for the two COUNT values for recipient_id and arr_id - and the Sum(ba.calculated_amount).
I think that the COUNTS actually need to be DISTINCT COUNTS at the "FY-and-REGION" level, but the current SQL is generating a COUNT (of all non-Null values) rather than a DISTINCT and only at the FY level.
The SUM needs to be a SUM at the "FY-and-REGION" level, but the current SQL is generating a SUM only at the FY level.
===========
select fy.fy_long fiscal_year,
reg.region_ename,
count(r.recipient_id),
count(arr.arr_id),
Sum(ba.calculated_amount)
from abcd.arrangement arr,
abcd.arr_transaction_activity ata,
abcd.budget_allocation ba,
abcd.mv_region reg,
abcd.fiscal_year fy,
abcd.recipient r
where ata.arr_id = arr.arr_id
and ba.trg_arr_tx_act_id = ata.arr_tx_act_id
and ba.fy_short = fy.fy_short
and r.recipient_id = arr.recipient_id
group by fy.fy_long, reg.region_ename
===========
If anyone has some advice on DISTINCT COUNTS and HIERARCHICAL GROUPING in PL/SQL it would be appreciated...
Thanks in advance....
The SQL below is giving bad results for the two COUNT values for recipient_id and arr_id - and the Sum(ba.calculated_amount).
I think that the COUNTS actually need to be DISTINCT COUNTS at the "FY-and-REGION" level, but the current SQL is generating a COUNT (of all non-Null values) rather than a DISTINCT and only at the FY level.
The SUM needs to be a SUM at the "FY-and-REGION" level, but the current SQL is generating a SUM only at the FY level.
===========
select fy.fy_long fiscal_year,
reg.region_ename,
count(r.recipient_id),
count(arr.arr_id),
Sum(ba.calculated_amount)
from abcd.arrangement arr,
abcd.arr_transaction_activity ata,
abcd.budget_allocation ba,
abcd.mv_region reg,
abcd.fiscal_year fy,
abcd.recipient r
where ata.arr_id = arr.arr_id
and ba.trg_arr_tx_act_id = ata.arr_tx_act_id
and ba.fy_short = fy.fy_short
and r.recipient_id = arr.recipient_id
group by fy.fy_long, reg.region_ename
===========
If anyone has some advice on DISTINCT COUNTS and HIERARCHICAL GROUPING in PL/SQL it would be appreciated...
Thanks in advance....