开发者

Missing expression and then group function not allowed error

开发者 https://www.devze.com 2023-02-13 13:22 出处:网络
I am wondering what i am doing wrong. I have 2 tables ODETAILS and ORDERS ODETAILS has the following columns: ONO, PNO, QTY, COST

I am wondering what i am doing wrong. I have 2 tables

ODETAILS and ORDERS

ODETAILS has the following columns: ONO, PNO, QTY, COST

ORDERS has the following columns: ONO, CNO, ENO, RECEIVED, SHIPPED, ORDER_COST

UPDATE ORDERS
SET ORDER_COST= 1 *  SUM(
    SELECT COST
    FROM ODETAILS
    WHERE ORDERS.开发者_如何学编程PNO=ODETAILS.PNO
    )
;


try this. (sum was in wrong place)

UPDATE ORDERS
SET ORDER_COST= 1 *  (
    SELECT SUM(COST)
    FROM ODETAILS
    WHERE ORDERS.PNO=ODETAILS.PNO
    )
;


HAH. figured it out. there is no PNO in ORDERS table.

UPDATE ORDERS
SET ORDER_COST= 
    (SELECT sum(COST)
    FROM ODETAILS
    WHERE ORDERS.ONO=ODETAILS.ONO);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号