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 |
|
mastro78
Starting Member
9 Posts |
Posted - 2008-11-05 : 13:28:11
|
| I have a table where I need to delete duplicate records, however, there is a DateChange field where I'd like to keep all the newest records in that case. So if there are 3 John Smiths, I'd like to keep the duplicate that has the most recent date change. Thanks for your help!!! |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-11-05 : 13:47:13
|
DELETE fFROM (select row_number() over (partition by name order by datechange desc) as recidfrom table1) as fwhere recid > 1 E 12°55'05.63"N 56°04'39.26" |
 |
|
|
mastro78
Starting Member
9 Posts |
Posted - 2008-11-05 : 13:52:53
|
| Question on the select row_number() piece. I'm fairly new to more advanced SQL so I'm not sure what are keywords and what aren't. Thank you for your help! |
 |
|
|
mastro78
Starting Member
9 Posts |
Posted - 2008-11-05 : 15:28:12
|
| Never mind I understand it. Thank you for your help. |
 |
|
|
|
|
|