什麼是錯的這個SQL語句,我不斷收到此錯誤:ORA-00979:不是GROUP BY表達式ORDERDETAILS
SQL錯誤:ORA-00979:不是GROUP BY表達式 00979. 00000 - 「不是一個GROUP BY表達式」 *原因:
*操作:
SELECT orderdetails.orderid,
orderdate,
sum (quantity *(unitprice - unitprice * discount))as "Order Total"
FROM orderdetails
INNER JOIN orders orders on orderdetails.orderid = orders.orderid
WHERE customerid = 'ERNSH'
GROUP BY orderdetails.orderid
ORDER BY "Order Total" desc;
如果我有像發貨另一個變量?
SELECT orderdetails.orderid, orderdate, NVL2(Shippeddate, "Not Shipped" , "Shipped") as "Shipped" ,sum (quantity *(unitprice - unitprice * discount))as "Order Total" FROM orderdetails
INNER JOIN orders orders on orderdetails.orderid = orders.orderid
WHERE customerid = 'ERNSH'
GROUP BY orderdetails.orderid , orderdate, Shipped
ORDER BY "Order Total" desc;
將訂單日期添加到GROUP BY子句---'order by orderdetails.orderid,orderdate' – GurV
任何原因您將餐單'orders'別名爲'orders'?唯一可能的用途是,您可以通過名稱'orders'而不是名稱'orders'來引用它。我沒有看到... – mathguy