order_id
, quantity
, and using aggregate functions AVG(quantity)
and MAX(quantity)
grouped by order_id
.HAVING
clause to compare the maximum quantity of each order with the maximum average quantity obtained from the subquery.order_id
of the orders that meet the imbalanced condition.erDiagram OrdersDetails { int order_id int product_id int quantity order_id product_id PK }