I'm having problems updating a column in one of my tables. I have a table called ORDERS, I added a new column to the table that represents the total cost of an order. I get the total cost by using a query that calculates the cost. Now I'm trying to use update using that select query to fill that column in the table. This is what I have:
update ORDERS
set TOTAL_COST = (
select sum((p.COST*i.QUANTITY)*(1-o.DISCOUNT))+delivery(o.DELIVERY) as TOTAL_COST
from PRODUCT p, ITEM i, ORDERS o
where p.ID_PRODUCT = i.ID_PRODUCT and i.ID_ORDER = o.ID_ORDER
group by o.ID_ORDER, o.DISCOUNT, o.DATE, o.DELIVERY);
My query returns the total cost of every order and that is what I want to have in my table. I get an "single-row subquery returns more than one row" error. I don't know what I'm doing wrong, any suggestions??