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 |
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2012-03-01 : 19:25:28
|
| Hi,below is the data I have in table Sample. As you can see for TRF_UODID there are many 107726 records(there is more data which has multiple rows for a single TRF_UODID - not shown below). I want to select data such that only the top 1077726 row should be seen. Similarly, in my whole data, I would like to select only unique TRF_UODID values and only the first one out of the whole list. TRF_UODID TRF_LABEL POINT_OF_SERVICE1077724 JA-B-950171 2958401077726 JA-941508 2951501077726 JA-941508 2958701077726 JA-941508 2958821077726 JA-941508 2958931077726 JA-941508 2959281077726 JA-941508 2959361077726 JA-941508 2959441077726 JA-941508 2959571077726 JA-941508 2959701077726 JA-941508 2959881077726 JA-941508 2960081077726 JA-941508 2960131077726 JA-941508 2960351077726 JA-941508 296053Thanks,Mavericky |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-01 : 19:37:38
|
something like thisselect *from( select rn = row_number() over (partition by TRF_UODID order by somecol), * from yourtable) twhere t.rn = 1 KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
mavericky
Posting Yak Master
117 Posts |
Posted - 2012-03-01 : 19:53:00
|
| Thanks khtan!!! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-03-01 : 20:40:47
|
welcome KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
|
|
|