programming-examples/sql/Subqueries/13. Write a queries to find all orders with order amounts which are on or above-average amounts for their customers.sql

6 lines
262 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*13. Write a queries to find all orders with order amounts which are on or above-average amounts for their customers.*/
SELECT *
FROM orders a
WHERE purch_amt > =
(SELECT AVG(purch_amt) FROM orders b
WHERE b.customer_id = a.customer_id);