mysql - Group by doesn't give me the newest group -


i trying distinct result table, , people said should use group by. worked half way... distinct result result not newest thread... table contains status on apartments several buildings. apartments can found many times since it's history table... need make select retrieves distinct apartments current status.

id    building apartment_id  status 1     1        1             1 2     1        1             2 3     2        2             3 4     2        4             2 5     2        3             2 6     2        5             1 7     2        6             1 

i'm working with:

select * `ib30_history` group apartment_id, building order id desc 

select    building   , appartment_id   , status  ib30_history id = ( select max(id) ib30_history b               b.building = a.building , b.appartment_id = a.appartment_id) 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -