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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-07-19 : 21:13:04
|
Kwang writes "Hi! First, thanks for the great site! I have found many great tips and appreciate what you are doing. (<--not just ass kissing so you'll help me with my problem...)Anyway, I've searched through your site and I coundn't come up with anything that might solve my problem. I have this table:eventID eventDate------- ---------1 6/1/20011 6/2/20011 6/3/20011 6/4/20011 6/5/20013 6/1/20013 6/2/20013 6/3/20013 6/4/20014 6/1/20014 6/2/20014 6/3/2001 What I need to do is return a recordset which contains the 2 latest records for each eventID. So the resulting recordset would be likeeventID eventDate------- ---------1 6/4/20011 6/5/20013 6/3/20013 6/4/20014 6/2/20014 6/3/2001 I have hammered together a solution by using a cursor to step through each distinct eventID and inserting into a copy of the table the top 2 records for each eventID.I was hoping there would be a better way to do this. Any help will be greatly appreciated. I am using Windows 2000 and SQL 2000 with all the latest updates.Thanks!Kwang Kim" |
|
|
|
|
|