Restrict Groups with “Having”
SELECT Category, Avg(Price), Min(Quantity), Sum(Price*Quantity)
FROM Product
WHERE SupplierID in (‘1’, ‘2’) or SupplierID is null
GROUP BY Category
HAVING Min(Quantity) < 5
The ‘WHERE’ clause is always evaluated before the ‘HAVING’ clause.
Previous slide
Next slide
Back to first slide
View graphic version