1. One row per group
GROUP BY splits the rows into piles, then runs the aggregate on each pile:
SELECT category, COUNT(*) AS items FROM products GROUP BY category;
Imagine sorting the shop’s products into baskets by category, then counting each basket. You get one row per category.
Rule: every column in SELECT is either in GROUP BY or inside an aggregate like COUNT/SUM.
SELECT category,
MAX(price) AS top_price
FROM products
GROUP BY category;
Challenge: Items per category
Show each category with the number of products in it, named items. Columns: category, items.