At least one item is solved with this code
----------------------------------------------------
SELECT Emp.EmpName,
Order.ItemID,
SUM(Order.Quantity) Total_Quantity,
SUM(Order.Price) Total_Price
FROM Emp
INNER JOIN Order ON Order.CustID = Emp.CustID
GROUP BY Emp.EmpName,
Order.ItemID
----------------------------------------------------
A single order is solved with adding HAVING clause
----------------------------------------------------
SELECT Emp.EmpName,
Order.ItemID,
SUM(Order.Quantity) Quantity,
SUM(Order.Price) Price
FROM Emp
INNER JOIN Order ON Order.CustID = Emp.CustID
GROUP BY Emp.EmpName,
Order.ItemID
HAVING COUNT(*) = 1
|