sql - select values to update -
i'm trying input last value select statement update. i've tried query below got error: gives me error: missing right parenthesis.
update dt2112b2.postgraduate_order set order_total = (select item_cost * order_quantity dt2112b2.order_stock, dt2112b2.postgraduate_order dt2112b2.order_stock.menu_item = dt2112b2.postgraduate_order.menu_item , rownum <=1 order postgraduate_order.order_id desc);
i think want correlated subquery. have issue rownum
-- choosing arbitrary row before order by
. order by
nothing. perhaps want sum:
update dt2112b2.postgraduate_order po set order_total = (select sum(item_cost * order_quantity) dt2112b2.order_stock os os.menu_item = po.menu_item );
or if want matching order largest order id:
update dt2112b2.postgraduate_order po set order_total = (select max(item_cost * order_quantity) keep (dense_rank first order order_id desc) dt2112b2.order_stock os os.menu_item = po.menu_item );
Comments
Post a Comment