WHAT I DID
You should achieve this by using an aggregation function such as MAX()
applied to the column id
and then grouped by device
remaining of
this mode
SELECT MAX(id), device from tabla group by device;
The only thing you should replace is tabla
by the name of your table
If what you want is to show the rest of the columns, it would be enough for you to do the following
SELECT MAX(id), device, columna3, columna4, columnaN
from tabla
group by device;
Where:
column1, column2, columnN are the names of the columns that
you want to be shown in the final result of your query; enough that
put the name that corresponds to each one and separate them by
coma
UPDATE
If you want to show all the other columns but not write them one by one; your query should look like this
SELECT MAX(id), device, tabla.*
from tabla
group by device;
WHAT I DID
The important thing here is tabla.*
where table is the name of your table and when you put .*
we are telling you to bring all the columns