Problems / Orders Exceeding Customer Average / Editorial
(SELECT AVG(amount) FROM orders o2 WHERE o2.customer_id = o.customer_id)
groupBy("customer_id")
customer_id
amount > 1.5 * avg
customer_avg
order_id
Two customers in the data show why the boundaries matter. Orders of 50 and 150 average to 100 — the 150 order equals exactly 1.5× and the strict inequality excludes it. Three identical 80 orders can never be flagged: when every amount equals the average, nothing exceeds 1.5× of it. Also note the rounding split: compare against the raw average and round only the displayed column — rounding before comparing can flip boundary cases.
Solve Orders Exceeding Customer Average yourself →