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 |
|
nishanthnair
Starting Member
6 Posts |
Posted - 2010-06-02 : 02:26:15
|
| Hi,I have a requirement where I need to select rows from a table wherethe value in a column must come only once in the result set(avoiding other duplicates) that too the first unique value in the table (which is ordered by create date). e.g. table id Name distributerid 1 Nish 1000 2 John 1000 3 Jose 1005 4 Mike 1000 5 Steve 1005 The output must be1 Nish 10003 Jose 1005We need the distributerid to be appearing in the output only once and that too the row must be the first occurrence in the table. It will be really helpful if some one could help me in writing this query. Thanks a lotNishanthCheers,Nishanth |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-06-02 : 04:00:13
|
| select * from( select *,ROW_NUMBER()over(partition by distributerid order by id) as rid from yourtable)T where rid=1PBUH |
 |
|
|
nishanthnair
Starting Member
6 Posts |
Posted - 2010-06-02 : 04:58:11
|
| Thanks Idera!!Cheers,Nishanth |
 |
|
|
Sachin.Nand
2937 Posts |
Posted - 2010-06-02 : 05:55:19
|
| You are welcome.PBUH |
 |
|
|
|
|
|