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
 General SQL Server Forums
 New to SQL Server Programming
 how to distinct one column name and not distinct

Author  Topic 

Trininole
Yak Posting Veteran

83 Posts

Posted - 2010-09-29 : 17:27:09
Is there a way to distinct one column like "username" instead of trying to distinct a series of columns like firstname, lastname, address, phone, and zip??? How would i get a "distinct" username by itself without having to try and distinct the rest of those other columns?

Roger DeFour

robvolk
Most Valuable Yak

15732 Posts

Posted - 2010-09-29 : 17:33:59
You can GROUP BY username and use MIN() or MAX() on the other columns.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-09-30 : 12:03:25
but you do need to determine how you want other values to return. while grouping by username you can return only one set of values for the other fields. what should that set be? ie. should it be first,last or random one?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -