Chapter 8 · Window Functions
01. Rank Products by Price Within Category
Medium20 XPE-Commerce
The catalog team wants to rank products by price within each category. Return the category name, product name, price, and a rank (1 = most expensive). Use RANK() so ties share the same rank.
Tables
- PKidINT
- nameTEXT
- descriptionTEXT
- 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.