I want to (Add p.L_VALUE AND p.I_VALUE And with this result, Subtract c.con_value) subtract one column to another column in different table, the function below compiles successfully but the subtract result is not correct:
function CF_OP_QTYFormula return Number is V_QTY number(10); begin select sum(nvl(p.L_QTY, 0)) + sum(nvl(p.I_QTY, 0)) - sum(nvl(c.CON_QTY,0)) into V_QTY from raw_purchase p, raw_consum c WHERE p.ITEMCODE = c.ITEMCODE AND p.ITEMCODE = :ITEMCODE AND p.MONTH_YEAR BETWEEN '31-MAY-2010' AND ADD_MONTHS(:date1, -1); return v_qty; exception when no_data_found then return null; end;
;
after the SELECT statement (before thereturn
statement) – a_horse_with_no_name