Find Duplicate Emails using SQL Server 2000

Rajnilari2015
Posted by Rajnilari2015 under Sql Server category on | Points: 40 | Views : 194
Consider the below table

Declare @t Table(name varchar(20), email varchar(20))
insert into @t values ('name1', '1stEmail@email.com')
insert into @t values ('name1', '2ndEmail@email.com')
insert into @t values ('name1', '3rdEmail@email.com')
insert into @t values ('name2', '1stEmail@email.com')
insert into @t values ('name3', '1stEmail@email.com')
insert into @t values ('name3', '2ndEmail@email.com')
insert into @t values ('name4', '1stEmail@email.com')


Sql server 2000 approach to find the duplicate email entries

SELECT name,  EmailCount = count(email)
FROM @t
GROUP BY name
HAVING count(*) > 1


/* Result */
name EmailCount
name1 3
name3 2

Comments or Responses

Login to post response