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 |
spunkiegirl
Starting Member
9 Posts |
Posted - 2014-05-04 : 06:06:18
|
Good Morning,I have a table that looks like the below: I want to return only one of the CustNmbr records.CustNmbr Code UniqueID 10058 TM 110058 DIS 210058 REP-BANC 310059 TOS 410059 COMBINE 510059 REP-BANC 610076 TOS 710076 REP-BANC 810076 REP 910099 TM 1010099 REDO 11So I want my result set to look like the below:10058 TM 110059 TOS 410076 TOS 710099 TM 10Thank you! |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2014-05-04 : 08:01:04
|
[code]select *from( select *, rn = row_number() over (partition by CustNmbr order by UniqueID) from CustNmbr) dwhere d.rn = 1[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
MuralikrishnaVeera
Posting Yak Master
129 Posts |
Posted - 2014-05-05 : 01:00:15
|
There is one more way... SELECT * FROM #temp WHERE UniqueID IN (SELECT MIN(UniqueID) OVER(PARTITION BY CustNmbr) FROM #temp) ---------------Murali KrishnaYou live only once ..If you do it right once is enough....... |
|
|
spunkiegirl
Starting Member
9 Posts |
Posted - 2014-05-05 : 09:51:25
|
Thank you all so much! |
|
|
|
|
|