Example
SELECT LocationID,Shelf,Sum(Quantity) AS [Total Quantity]
FROM Production.ProductInventory
WHERE LocationID in (1,5)
GROUP BY LocationID,Shelf
HAVING Sum(Quantity) > 5000
ORDER BY LocationID
The 'where' clause filters out rows of data, based column values. The 'having' clause filters out groups of data based on aggregate functions.