L3 Q10 Advanced Level
Practice Question

Level 3 - Question 10: Complex Real-World Business Scenario

Scenario

You work for an online retail company. Management wants a comprehensive report showing:

  • Top 5 customers by total purchase amount
  • Their most recent order date
  • Number of orders placed
  • Average order value
  • Only include customers who have placed more than 2 orders in the last year

Task: Write a complex query combining JOINs, aggregations, subqueries, and date functions to generate this business intelligence report.

Sample Schema: customers

customer_id name email
1 Alice Johnson alice@example.com
2 Bob Smith bob@example.com
3 Carol White carol@example.com

Sample Schema: orders

order_id customer_id order_date amount
101 1 2024-08-15 250.00
102 1 2024-09-10 300.00
103 1 2024-10-05 150.00
104 2 2024-07-20 400.00
105 2 2024-09-25 350.00
106 2 2024-10-01 200.00