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 |
|
tooba
Posting Yak Master
224 Posts |
Posted - 2011-09-20 : 13:50:04
|
| Hi, May be this is basic question, I have table has duplicate record here is my table structureTABLEA = ID,LNAME,FNAME,PHI want whole table with distinct ID, if i use SELECT DISTINCT ID FROM TABLEA, i can get what i want, but i want whole table with distinct ID, which syntax whould i use? Thanks. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-20 : 22:13:23
|
| [code]SELECT ID,LNAME,FNAME,PHFROM(SELECT ROW_NUMBER() OVER (PARTITION BY ID ORDER BY LNAME,FNAME) AS Rn,ID,LNAME,FNAME,PHFROM TABLEA)tWHERE Rn=1[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|