group by follow by order by in mysql -
i want find out query in group followed order by.
my table resource_monitor
id | server_ip | rdp_connection 1 | 192.168.1.45 | 9 2 | 192.168.1.46 | 12 3 | 192.168.1.45 | 8 4 | 192.168.1.45 | 4 5 | 192.168.1.46 | 3
i have user query
select * resource_monitor group server_ip order id desc
this gives me result
id | server_ip | rdp_connection 2 | 192.168.1.46 | 12 1 | 192.168.1.45 | 9
but want unique server_ip's last record
id | server_ip | rdp_connection 4 | 192.168.1.45 | 4 5 | 192.168.1.46 | 3
you can subquery following
select * (select * resource_monitor order id desc) test group test.server_ip
Comments
Post a Comment