开发者

Missing expression and then group function not allowed error

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜