CREATE TABLE dbo.Customer( ID INT, FirstName VARCHAR(100),LastName VARCHAR(100),Age INT)
GO
INSERT INTO dbo.Customer
VALUES(1,'Aamir','Shahzad',34) ,(1,'Aamir','Shahzad',34) ,(2,'Raza','M',32) ,(3,'Sukhjeet','Singh',27) ,(4,'Sukhjeet','Singh',28)
SELECT * FROM dbo.Customer
Find duplicate records by using Group by:
SELECT FirstName, LastName, COUNT(*) AS RecordCnt FROM dbo.Customer GROUP BY FirstName, LastName HAVING COUNT(*) > 1
No comments:
Post a Comment