I got a (guess) really simple question here. I use the query below, to get the lowest prices of some objects. I get the lowest price but the price id (pid) is not the one of the lowest price but another one.
What should i do to get the right pid too?
Table
pid, oid, price
1, 10, 300
2, 10, 400
3, 10, 500
4, 20, 310
5, 20, 410
6, 20, 510
Query
SELECT pid, oid, min(price)
FROM prices
group by oid