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 2000 Forums
 Transact-SQL (2000)
 Duplicate rows - help with SELECT

Author  Topic 

Johnyalm
Starting Member

49 Posts

Posted - 2004-10-27 : 13:39:51
I have a table with registered users. Some people are nasty enough to register twice or more.

Now I would like to selct only those rows that has the same e-mail in the field email.

So if there are 2 rows with the address double@double.com I would like the SELECT to get them for me...

Anybody who can help me with this SELECT?

www.mirrorgate.com

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-27 : 13:43:12
SELECT Email, COUNT(*)
FROM Table1
GROUP BY Email
HAVING COUNT(*) > 1 --or = 2 if you don't care about 3 or more registrations

Tara
Go to Top of Page

Johnyalm
Starting Member

49 Posts

Posted - 2004-10-27 : 13:46:09
THANKS!

It took 3 minutes and 21 seconds to get the answer!

You are all great!



www.mirrorgate.com
Go to Top of Page

VIG
Yak Posting Veteran

86 Posts

Posted - 2004-10-27 : 13:46:19
select *
from MyTable t
join
(select email from MyTable group by email having count(*) >1) t1
on t.email=t1.email
Go to Top of Page
   

- Advertisement -