SQL Get Latest Unique Rows

Posted by Simpleton on Stack Overflow See other posts from Stack Overflow or by Simpleton
Published on 2010-04-24T01:34:27Z Indexed on 2010/04/24 1:43 UTC
Read the original article Hit count: 262

Filed under:
|
|
|
|

I have a log table, each row representing an object logging its state. Each object has a unique, unchanging GUID. There are multiple objects logging their states, so there will be thousands of entries, with objects continually inserting new logs. Everytime an object checks in, it is via an INSERT.

I have the PrimaryKey, GUID, ObjectState, and LogDate columns in tblObjects. I want to select the latest (by datetime) log entry for each unique GUID from tblObjects, in effect a 'snapshot' of all the objects.

How can this be accomplished?

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql