SQLTeam.com | Weblogs | Forums

Select records by compare LName and FName


#1

I have table where field RecNo can repeat but unfortunately some records in the table have wrong entered value into that field. How select all RecNo where LastName and FirstName is the same?

Thanks.


#2
SELECT  RecNo ,
        LName ,
        Fname
FROM    Tbl
GROUP BY RecNo ,
        LName ,
        Fname
HAVING  COUNT(*) > 1

That is if you want to find all records that have the same RecNo, LName, and FName. If you want to find duplicate LName, FName combination regardless of the RecNo, remove RecNo from the SELECT clause and the Group By clause