I have a table which has three fields (item_id, source, and price). (item_id, source, and price) together make up the primary key.
item_id source price
------- ------- -----
1 paris 13
1 london 12
1 newyork 15
2 paris 22
2 london 15
2 newyork 14
For each item_id, I want to know the cheapest place to get it, and the price I will pay at that place. For the example above, I'd like to see the following output:
item_id source price
------- ------- ---------
1 london 12
2 newyork 14
Is there a simple way to do this without mentioning the table name twice? I'm using MySQL, so I can't use a WITH clause.
I've taken a look at the joined two-query solution in another user's question (Group related records, but pick certain fields from only the first record), but I'd really like to avoid mentioning the table twice. The problem is that the simple table in this question actually represents an inline view in my real problem which takes about 5 seconds to create per use, so I'm hoping to find alternatives.