Group By, Having
groupby1.sql
SELECT COUNT(*) AS 'number of items available', category FROM menu GROUP BY category
groupby2.sql
SELECT category, ROUND(AVG(price),2) AS 'average price' FROM menu GROUP BY category
groupby3.sql
SELECT category, ROUND(AVG(price),2) AS 'average price' FROM menu GROUP BY category HAVING AVG(price) > 15.00
- Explain how GROUP BY works.
- show the MAX price for each category group
- if you are struggling with the previous query:
SELECT MAX(price), category
FROM menu
GROUP BY ... - For the query you just wrote, show only the category groups HAVING MAX(price) > 20.0
- do another GROUP BY category query, this time using MIN. What does this tell us?