Select multiple unique lines in MySQL

Posted by MartinW on Stack Overflow See other posts from Stack Overflow or by MartinW
Published on 2010-05-20T14:34:04Z Indexed on 2010/05/20 14:50 UTC
Read the original article Hit count: 120

Filed under:
|
|

Hi,

I've got a table with the following columns:

ID, sysid, x, y, z, timereceived

ID is a unique number for each row.

sysid is an ID number for a specific device (about 100 different of these)

x, y and z is data received from the device. (totally random numbers)

timereceived is a timestamp for when the data was received.

I need a SQL query to show me the last inserted row for device a, device b, device c and so on.

I've been playing around with a lot of different Select statements, but never got anything that works. I manage to get unique rows by using group by, but the rest of the information is random (or at least it feels very random).

Anyone able to help me?

There could be hundreds of thousands records in this table.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql