Chapter 9 · Interview Level
39. Deduplicate Reviews with ROW_NUMBER
Hard40 XPE-Commerce
Some customers may have left multiple reviews for the same product. For each customer-product pair, keep only the most recent review. Return the review id, product_id, customer_id, rating, and review_date.
Tables
- PKidINT
- FKproduct_id→ products.idINT
- FKcustomer_id→ customers.idINT
- ratingINT
- commentTEXT
- review_dateTEXT
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.