Skip to main content
All Problems
hard0% acceptance

Rank Products by Price Within Category

For each product, show its name, category_id, price, and its rank within its category based on price (most expensive = rank 1). Use RANK() so tied prices share the same rank. Sort by category_id, then rank.

Schema

🔑idINT
nameTEXT
🔗category_idINT
priceREAL
costREAL
stock_quantityINT
created_atTIMESTAMP
postgresql

Run your query to see results

Press Ctrl + Enter to execute