Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sfjtraps
Yak Posting Veteran
65 Posts |
Posted - 2010-01-28 : 14:22:38
|
Hi,Does anyone know how to select the most current record from a table? What to put in the WHERE clause?Here is my querySELECT * FROM Snapshot wHERE Event = 'liveEventTag' Please help. I only want the most current record.Thanks,sfjtraps |
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-01-28 : 14:49:02
|
How do you define "most current record"...Do you have a datetime field in the table which you can use? |
|
|
sfjtraps
Yak Posting Veteran
65 Posts |
Posted - 2010-01-28 : 15:04:25
|
I do have a dateTime field as follows:2010-01-28 12:53:01.280 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-01-28 : 15:08:17
|
Then you can do it this way..select top 1 * from <urtable>order by <urdatetimefield> desc |
|
|
raky
Aged Yak Warrior
767 Posts |
Posted - 2010-01-29 : 05:42:33
|
try thisSELECT top 1 * FROM SnapshotwHERE Event = 'liveEventTag' order by <DateField> descNote: This gives the top most record which has Event as LiveEventTag |
|
|
|
|
|