oracle - Doing a calculation in sql without sum -
i have table generated sql using inner join, want calculate total cost of each order_id, example screen shot shows 4 orders order id 127, want combine total costs of each ordered item 127 1 number, same other order ids. price in table haven't specified in query.
i thinking of doing quantity* price, not sure how link order ids i've mentioned above.
many help:)
sql:
select p.carrier_id, o.aircraft_id, o.order_id, o.quantity orderline o inner join purchaseorder p on o.order_id = p.order_id;
my results far:
you want use group by
. need know rest of query give complete version, - roughly:
select p.carrier_id, o.aircraft_id, o.order_id, sum(o.quantity) -- columns orderline o inner join purchaseorder p on o.order_id = p.order_id -- tables , join group p.carrier_id, o.aircraft_id, o.order_id;
you might think need group order id, rule of thumb "group you're not counting (or summing...)
also, pointed out other answer, if have record of prices, can sum(o.quantity*p.price)
or close obtain total price of each order.
Comments
Post a Comment