I have a database of customers and products and purchases of products made by customers. Some customers have purchased multiple products.
I need to create a report of all customers who purchased products ordered by the cost of the products they purchased.
One way is to loop through all customers who purchased products and then execute a subsequent search of products they purchased, ordered by cost and LIMIT by 1. The issue is the order of the customer list is not ordered by cost of product.
I am sure there is a way to create a single MySQL query (sub SELECT? UNION?) whih will simply return a single matrix of customers and the most expensive product they purchased ordered by purchase price.
I am drawing a blank... Any help would be appreciated.