Mysql query to get distict hotel id with minimum price and star?

Posted by user1325929 on Stack Overflow See other posts from Stack Overflow or by user1325929
Published on 2012-04-12T11:22:00Z Indexed on 2012/04/12 11:30 UTC
Read the original article Hit count: 177

Filed under:

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

© Stack Overflow or respective owner

Related posts about mysql