Mysql query to get distict hotel id with minimum price and star?
- by user1325929
Current table
hotel_id | price | star
1100 | 1999 | 3
1100 | 1565 | 3
1100 | 2000 | 3
1101 | 2010 | 4
1101 | 2050 | 4
1102 | 5599 | 5
1102 | 6599 | 5
Required result: distinct hotels with minimum price and it's star
hotel_id | price | star
1100 | 1565 | 3
1101 | 2010 | 4
1102 | 5599 | 5
I wrote query as SELECT DISTINCT hotel_id, min(price),star
FROM MyTable. It is giving only 1 row instead of 3