Imagine data in this format:
Customer, Object, Price
[William, Orange, 100p
William, Apple, 80p
William, Banana 60p
Casper, Cola, 150p
Casper, Beer, 120p
Casper, Peanuts, 200p]
I am interested in extracting the most and least expensive purchase for every buyer, along with the actual item.
The output should look like this.
Customer, MostExpItem, MostExpCost, LeastExpItem, LeastExpCost
William, Orange, 100p, Banana, 60p
Casper, Peanuts, 200p, Beer, 120p
Any pointers? I can use group by to easily extract the min/max values. Is a subquery required for this problem?