VMaxx.net
VMaxx techie board!
 
 FAQ   Search   Memberlist   Usergroups   Register 
 Profile   Log in to check your private messages   Log in 

Looking for duplicates

 
Post new topic   Reply to topic    VMaxx.net Forum Index -> SQL Server
View previous topic :: View next topic  
Author Message
vm



Joined: 27 Dec 2003
Posts: 50

PostPosted: Fri Oct 19, 2007 7:41 pm    Post subject: Looking for duplicates Reply with quote

Found this here. Worked great on my test db.
Quote:
select email, count(email) as numoccurrences from users
group by email having (count(email)>1)


I need to figure how to check more than one field of data.
Back to top
View user's profile Send private message
vm



Joined: 27 Dec 2003
Posts: 50

PostPosted: Fri Oct 19, 2007 8:10 pm    Post subject: Reply with quote

I found out how to check for two columns being duplicated:
Code:
select TheName, email,
count(TheName) as NumOccurName,
count (email) as NumOccurEmail from users
group by TheName, email
having (count(TheName)>1)
and (count(email)>1)

For what I need - 6 rows being duplicated is the limit.
Back to top
View user's profile Send private message
vm



Joined: 27 Dec 2003
Posts: 50

PostPosted: Fri Oct 19, 2007 8:57 pm    Post subject: Reply with quote

For 6 fields:
Code:
Select TheDate, TheTime, TheSID, TheIP, TheDomain, TheNetwork,
count(TheDate) as NumOccurDate,
count(TheTime) as NumOccurTime,
count(TheSID) as NumOccurSID,
count(TheIP) as NumOccurIP,
count(TheDomain) as NumOccurDomain,
count(TheNetwork) as NumOccurNetwork from Users1
group by TheDate, TheTime, TheSID, TheIP, TheDomain, TheNetwork
having
(count(TheDate)>1) and
(count(TheTime)>1) and
(count(TheSID)>1) and
(count(TheIP)>1) and
(count(TheDomain)>1) and
(count(TheNetwork)>1)
Back to top
View user's profile Send private message
vm



Joined: 27 Dec 2003
Posts: 50

PostPosted: Fri Oct 19, 2007 10:46 pm    Post subject: Reply with quote

All of the above is unneccessary.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    VMaxx.net Forum Index -> SQL Server All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2002 phpBB Group