Display product id and total quantity for products that have been sold more than once. Consider only those sale instances when the quantity sold was more than 1.
DATABASE Structure given
Salesman (Sid, Sname, Location) Product (Prodid, Pdesc, Price, Category, Discount) Sale (Saleid, Sid, Sldate, Amount) Saledetail (Saleid, Prodid, Quantity)
My answer
SELECT Prodid, MAX(SUM(Quantity)) "QTY_SOLD"
FROM Saledetail
GROUP BY Prodid HAVING Quantity>1;
I am not getting expected output. What's wrong in this query?
EXPECTED OUTPUT
PRODID | QTY_SOLD |
---|---|
102 | 11 |