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

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -