mysql - Select last record in each group -


i have table:

id    group_id    name    linked_group 1     1           name1 2     1           name2 3     1           name3 4     1           name4 5     2           name5 6     2           name6   3 7     2           name7 8     3           name8 9     3           name9 10    4           name10 11    4           name11 

i need retrieve last record in each group linked_group:

id    group_id    name    linked_group 4     1           name4 9     3           name9 11    4           name11 

how this? p.s. need ignore group_id = 2, because group_id need union group_id = 3

try this

select g.id,g.group_id,g.name,g.linked_group grouptable g left join grouptable g2  on (g.group_id = g2.group_id , g.id < g2.id) g2.id null; 

enter image description here


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -