alexjamesbrown:
For example:
DealID | TariffID | HandsetID | PhonePrice |
1 | t1 | 1234 | 12.99
2 | t1 | 1234 | 102.44
3 | t1 | 1234 | 139.45
4 | t2 | 1234 | 23.52
5 | t2 | 1234 | 123.52
6 | t2 | 1234 | 2.52
7 | t3 | 1234 | 23.52
You can try any of the below
select min(DealID), TariffID, HandsetID, min(PhonePrice)
from test_table
group by TariffID, HandsetID
or
select max(DealID), TariffID, HandsetID, min(PhonePrice)
from test_table
group by TariffID, HandsetID