I have this table:
+--------+---------+-----------+------------+
| bed_id | bed_num | place_id | bed_date |
+--------+---------+-----------+------------+
| 1 | 150 | 1 | 1244344305 |
| 2 | 250 | 1 | 1244345469 |
| 3 | 145 | 2 | 1244348496 |
| 3 | 146 | 2 | 1244348497 |
+--------+---------+-----------+------------+
I want to select all the unique place_id
s with most recent date of bed_num
so it should return something like below:
+--------+---------+-----------+------------+
| bed_id | bed_num | place_id | bed_date |
+--------+---------+-----------+------------+
| 2 | 250 | 1 | 1244345469 |
| 3 | 146 | 2 | 1244348497 |
+--------+---------+-----------+------------+
I have tried mixing GROUP BY and ORDER BY using distinct(place_id) AND max(bed_date)
But failing!
Thanks for any help! :)