|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Use DISTINCT and still retrieve all columnsI'm sure this is an old question.
I want to exclude duplicates in one column while still pulling all columns as if I used SELECT *. Can this be done? Thanks, Bank What does "exclude duplicates" mean? How will you handle the OTHER columns
in the table? What if they have different values for rows that have duplicate values of the column in question? -- Show quoteAdam Machanic Pro SQL Server 2005, available now http://www.apress.com/book/bookDisplay.html?bID=457 -- "Bank" <B***@discussions.microsoft.com> wrote in message news:49DDBF29-5F95-4D5B-BA4E-BA9EDB9F4EB8@microsoft.com... > I'm sure this is an old question. > > I want to exclude duplicates in one column while still pulling all columns > as if I used > SELECT *. Can this be done? > > Thanks, Bank SELECT min(col1), min(col2), uniquecolumn
FROM tablename GROUP BY uniquecolumn Bank wrote:
> I'm sure this is an old question. Yes.> > I want to exclude duplicates in one column while still pulling all columns > as if I used > SELECT *. Can this be done? > Read my signature. If you give us a better spec we may be able to help you. -- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx -- |
|||||||||||||||||||||||