SQL Exercises: Find the highest purchase amount ordered by the each customer
SQL Aggregate Functions: Exercise-9 with Solution
Write a SQL statement to find the highest purchase amount ordered by the each customer with their ID and highest purchase amount.
Sample table: orders
SELECT customer_id,MAX(purch_amt) FROM orders GROUP BY customer_id;
Output of the Query:
customer_id max 3007 2400.60 3008 250.45 3002 5760.00 3001 270.65 3009 2480.40 3004 1983.43 3003 75.29 3005 948.50
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: Write a SQL statement which selects the highest grade for each of the cities of the customers.
Next: Write a SQL statement to find the highest purchase amount ordered by the each customer on a particular date with their ID, order date and highest purchase amount.
What is the difficulty level of this exercise?