Galactic High Spenders by Week: Track Weekly Top-Spending Customers with Aggregate Window Functions
Discover which customers spend the most credits each week at Xorthax’s trading post.
Xorthax wants to identify his wealthiest patrons by week. For each customer, show their total spending for each week, highlight which customers had the highest total spend during that week with a t/f, and the rank of each customer for the week. All spending figures should be based on the orderdetails table.
Write Your Query
Answer:
Explanation:
This mirrors analyzing customer spending over weekly periods to identify top spenders and monitor buying patterns.
You will practice joining tables, applying aggregate window functions, and ranking results within time-based groups.
This problem is labeled as Advanced. You don’t need to be an expert—just comfortable with SQL and willing to experiment. If you get stuck, the hints and solution will guide you step by step.
Yes. Every problem comes with optional hints you can reveal one at a time, plus a fully worked step-by-step solution. You decide how much help you want while practicing.
All problems on PracticeWindowFunctions.com are completely free and can be solved without creating an account. Right now there are over 80 practice problems, with new ones added regularly.