Most Expensive Purchase
Amazon is trying to identify their high-end customers. To do so, they first need your help to write a query that obtains the most expensive purchase made by each customer. Order the results by the most expensive purchase first.
User 1 have 2 purchases (150 and 35.90) with 150 being the most expensive purchase whereas user 2 have 3 purchases (349.99, 199.95, and 551.20) and 551.20 is their most expensive purchase.
User 3 only have 1 purchase at 13.30 and hence it's their most expensive purchase. The output is then sorted by the most expensive purchase to the least expensive.
Goal: Find the most expensive purchase made by each customer.
This question requires knowing the aggregate function . You can read more about the function here here.
We can obtain the most expensive purchase by finding for the maximum purchase amount using the function, and then grouping them respectively by each customer as requested in the question.
Also, do not forget to order the results by the most expensive purchase.