Top Three Per Customer
SELECT customer_id, order_id, total
FROM orders
WHERE row_number() OVER (PARTITION BY customer_id ORDER BY total DESC) <= 3;
What happens when this runs?
Sign in to answer questions and track your progress
Sign InSELECT customer_id, order_id, total
FROM orders
WHERE row_number() OVER (PARTITION BY customer_id ORDER BY total DESC) <= 3;
What happens when this runs?
Sign in to answer questions and track your progress
Sign In