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
 Eliminating Single Entries

Author  Topic 

pwebley
Starting Member

6 Posts

Posted - 2012-02-02 : 15:03:30
In Excel I am very familiar with the concept of eliminating duplicates in a single column. Now that I am learning SQL I would like to know the quickest way to code a command that would eliminate only single entries and keep duplicate values in a single field. Is this possible? Any help would be appreciated.

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2012-02-02 : 15:06:29
Look up count, group by and having.
Your query will look something like this:
Select column, count(1)
From table
Group by column
Having count(1) > 1


Duane.
Go to Top of Page

pwebley
Starting Member

6 Posts

Posted - 2012-02-02 : 16:31:18
Thank you!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2012-02-02 : 21:25:44
are you looking for retrieving records with out duplicate value

or

you do not want duplicate value to store in the table ?



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -