SQL - How to count duplicate record

I have a table with firstName, lastName and other fields,  I will like to count all the rows have the same firstName and lastName.
tommym121Asked:
Who is Participating?
 
Deepak ChauhanConnect With a Mentor SQL Server DBACommented:
try these hope so you will be got your result

 select a.firstname, a.lastname from table_A as a
 join Table_A as b on a.firstname=b.fistname and a.lastname=b.lastname

or

select firstname, lastname from (
select row_number() over( partition by firstname, lastname order by firstname) as row,
firstname, lastname from aaa) a where row >1

or
select count(*) from (
select row_number() over( partition by firstname, lastname order by firstname) as row,
firstname, lastname from aaa) a where row >1
0
 
AnuroopsunddCommented:
SELECT firstname, lastname, COUNT(*)  FROM person  GROUP BY firstname, lastname  HAVING COUNT(*) > 1;
0
 
Anthony PerkinsCommented:
Something like this perhaps:
SELECT COUNT(DISTINCT firsname + lastname)
FROM YourTable
0
 
tommym121Author Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.