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 |
|
BendJoe
Posting Yak Master
128 Posts |
Posted - 2010-05-19 : 11:32:05
|
| DocID UserID Date400005564 26 2010-03-15 08:42:10.767400005564 27 NULL400005564 40 2010-03-11 00:00:00.000I need the UserID for the row which has the max (date) from the above data where DocID will be a parameter @docID.Thanks |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-05-19 : 11:46:35
|
If you are using SQL Server 2005 and above.select * from (select row_number () over (partition by DocID order by Date desc) as seq, * from table1) twhere t.seq = 1 and t.DocID = @docID |
 |
|
|
|
|
|