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 |
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2012-07-01 : 12:05:39
|
I have three columnsAccountno, Website, RecidThe recid is an incremental unique id. so the higher it is the more recent it is.Some of the accounts have several website addresses...I just want the most recent oneso my results contain only 1 row per customer accountHope that makes sense - thanks in advance |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-07-01 : 12:13:41
|
[code]select *from( select *, row_no = row_number() over (partition by accountno order by recid desc) from yourtable) dwhere d.row_no = 1[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
icw
Constraint Violating Yak Guru
378 Posts |
Posted - 2012-07-01 : 14:11:00
|
Thanks very much Khtan.Hope you have a great day! |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|