select sum(vital_dashboard_mv.received_qty) totalqty from (
select vital_dashboard_mv.supplier, vital_dashboard_mv.received_qty,
(DECODE(vital_dashboard_mv.received_qty,0,vital_dashboard_mv.master_po_qty,vital_dashboard_mv.received_qty) / totalqty) * 100 Percentage
from vital_dashboard_mv where vital_dashboard_mv.period = 4
union
select 'Total', sum(vital_dashboard_mv.received_qty), 0
from vital_dashboard_mv where vital_dashboard_mv.period = 4
) order by received_qty
|