SkyHog
Touchdown! Greaser!
- Joined
- Feb 23, 2005
- Messages
- 18,431
- Location
- Castle Rock, CO
- Display Name
Display name:
Everything Offends Me
I can't believe I can't wrap my brain around a way to do this.
I have a table with a series of position updates in it. Multiple people tracked simultaneously in the same table. Every update is timestamped, and there is a history of every position update kept in the same table.
The columns in the table are as such:
Lat (double), Long (double), PosID (int), UserId (ind), TimeStamp (TimeStamp)
PosID will always be unique, but everything else may be duplicated with different stuff, presumably, however, each user will never have duplicated TimeStamp.
I want to pull the most recent position for every UserId. Any ideas?
The best I can figure is how to pull the most recent position across the entire table, but I want the most recent per UserId.
Any help is appreciated. If it helps, here's some sample data:
So, what I want to return in my result set is:
Thanks in advance!
I have a table with a series of position updates in it. Multiple people tracked simultaneously in the same table. Every update is timestamped, and there is a history of every position update kept in the same table.
The columns in the table are as such:
Lat (double), Long (double), PosID (int), UserId (ind), TimeStamp (TimeStamp)
PosID will always be unique, but everything else may be duplicated with different stuff, presumably, however, each user will never have duplicated TimeStamp.
I want to pull the most recent position for every UserId. Any ideas?
The best I can figure is how to pull the most recent position across the entire table, but I want the most recent per UserId.
Any help is appreciated. If it helps, here's some sample data:
Code:
Lat Long PosID UserID TimeStamp
35.233 -89.123 86 7 1284523386
48.221 -64.218 85 12 1284523381
48.220 -64.217 84 12 1284523361
12.221 -2.218 83 9 1284523162
12.221 -2.214 82 9 1284523142
35.233 -89.120 81 7 1284523111
Code:
Lat Long PosID UserID TimeStamp
35.233 -89.123 86 7 1284523386
48.221 -64.218 85 12 1284523381
12.221 -2.218 83 9 1284523162
Last edited: