0

This is what I have so far:

SELECT 
  Product_T.PRODUCTID, 
  Product_T.PRODUCTLINEID, 
  Product_T.PRODUCTDESCRIPTION, 
  Product_T.PRODUCTFINISH, 
  Product_T.PRODUCTSTANDARDPRICE, 
  Product_T.PRODUCTIONHAND, 
  OrderLine_T.ORDERLINEID, 
  OrderLine_TORDERID, 
  OrderLine_TPRODUCTID, 
  OrderLine_T.ORDEREDQUANTITY 
FROM 
  Product_T,
  OrderLine_T
WHERE 
  Product_T.ProductID = OrderLine_T.ProductID
AND 
  SUM(OrderLine_T.ORDEREDQUANTITY) > 20;

I get this message:

ORA-00934: group function is not allowed here 

Any ideas? any help is appreciated

4

1 回答 1

1

改用 HAVING

SELECT 
Product_T.PRODUCTID, 
Product_T.PRODUCTLINEID, 
Product_T.PRODUCTDESCRIPTION, 
Product_T.PRODUCTFINISH, 
Product_T.PRODUCTSTANDARDPRICE, 
Product_T.PRODUCTIONHAND, 
OrderLine_T.ORDERLINEID, 
OrderLine_TORDERID, 
OrderLine_TPRODUCTID, 
SUM(OrderLine_T.ORDEREDQUANTITY) OrderQty
FROM 
Product_T,
OrderLine_T
WHERE 
Product_T.ProductID = OrderLine_T.ProductID
GROUP BY
Product_T.PRODUCTID, 
Product_T.PRODUCTLINEID, 
Product_T.PRODUCTDESCRIPTION, 
Product_T.PRODUCTFINISH, 
Product_T.PRODUCTSTANDARDPRICE, 
Product_T.PRODUCTIONHAND, 
OrderLine_T.ORDERLINEID, 
OrderLine_TORDERID, 
OrderLine_TPRODUCTID
HAVING
SUM(OrderLine_T.ORDEREDQUANTITY) > 20;
于 2013-04-08T02:40:20.513 回答