You're managing an e-commerce platform and need to identify imbalanced orders - orders where customers have ordered an unusually high quantity of one particular product.
Given a table OrdersDetails with columns:
order_id(int): The unique identifier for each orderproduct_id(int): The product identifierquantity(int): Number of units ordered
An order is considered imbalanced if its maximum quantity (highest quantity of any single product) is strictly greater than its average quantity.
The average quantity of an order = (total quantity of all products) ÷ (number of different products)
Goal: Find all order IDs that represent imbalanced orders.
Example: If an order contains 3 products with quantities [10, 2, 3], then:
• Maximum quantity = 10
• Average quantity = (10+2+3)/3 = 5
• Since 10 > 5, this is an imbalanced order
Input & Output
Constraints
- 1 ≤ order_id, product_id ≤ 100
- 1 ≤ quantity ≤ 1000
- Each (order_id, product_id) combination is unique
- At least one order exists in the input