Chapter 6 · Subqueries
11. Most Expensive Product in Each Category
Medium20 XPE-Commerce
For each category, find the product with the highest price. Return the category_id, product name, and price. If there are ties, include all tied products. Sort by category_id.
Tables
- PKidINT
- nameTEXT
- FKcategory_id→ categories.idINT
- priceREAL
- costREAL
- stock_quantityINT
- created_atTIMESTAMP
Need help?
Ask Sol
AI tutor — looks at your current query and nudges you, without spoiling the answer.
Solution
Try the hints first — solving it yourself is what makes it stick.