programming-examples/sql/AggregateFunctions/Write a SQL statement to display customer details (ID and purchase amount) whose and highest purchase amount is more than 1000..sql

7 lines
324 B
MySQL
Raw Normal View History

2019-11-18 14:05:53 +01:00
/*Write a SQL statement to display customer details (ID and purchase amount) whose IDs are within the range 3002 and 3007
and highest purchase amount is more than 1000.*/
SELECT customer_id,MAX(purch_amt)
FROM orders
WHERE customer_id BETWEEN 3002 and 3007
GROUP BY customer_id
HAVING MAX(purch_amt)>1000;