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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Select Distinct

Author  Topic 

cable_si
Starting Member

20 Posts

Posted - 2011-03-07 : 10:59:24
Hi All

I am trying to run the below query on the below table

Select distinct recid, surname,forename, yr_reg from mytable

Forename RecID Surname Yr_Reg
elmer 20 fudd
Simon 8 0 Parry 1
Home 17 0 Simpson
Phil 120936 0 Little
Janet 117927 0 Robinson
elmer 20 0 fudd
Simon 8 0 Parry 1
Home 17 0 Simpson

however when i run my query my results are not distinct, the only person who displays as distinct is Simon Parry, im sure its something to do with the yr_reg column having blank/null values

the output of the query is
recid surname forename yr_reg
117927 RobinsonJanet
120936 Little Phil
17 Simpson Home
17 Simpson Home
20 fudd elmer
20 fudd elmer
8 Parry Simon 1

Can anyone advise how i could get a distinct list or why its not working correctly

thanks in advance

cable
   

- Advertisement -