Question : Calculate column with formula

i try to calculate and generate a column called 'Percentage', with  ( SUM of total quatity / Received qty) * 100 with
to_char(ROUND(SUM(DECODE(vital_dashboard_mv.master_po_qty)) / vital_dashboard_mv.received_qty * 100) Percentage
but the column did not generate
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
select * from (
select vital_dashboard_mv.supplier, vital_dashboard_mv.master_po_qty, to_char(ROUND(SUM(DECODE(vital_dashboard_mv.master_po_qty)) / vital_dashboard_mv.received_qty * 100) Percentage
from vital_dashboard_mv where vital_dashboard_mv.period = 4
union
select 'Total', sum(vital_dashboard_mv.received_qty)
from vital_dashboard_mv where vital_dashboard_mv.period = 4
) order by master_po_qty

Answer : Calculate column with formula

The first part of the union gives 3 result columns, the second 2,

union
select 'Total', sum(vital_dashboard_mv.received_qty) , null
from vital_dashboard_mv where vital_dashboard_mv.period = 4

will solve that problem
Random Solutions  
 
programming4us programming4us