Question : Invalid identifier on totalqty

i try to get the 'totalqty' generated from SUM(vital_dashboard_mv.received_qty) and use it in the next select statement for calculation. But it gave me
'invalid identifier : totalqty'
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
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

Answer : Invalid identifier on totalqty

Got it the other way...
Then this should do

cast((calc_value/ totalqty) * 100 as number(5,2))
Random Solutions  
 
programming4us programming4us