I have written a query to remove duplicate records from a table
;WITH a as
(
SELECT Firstname,ROW_NUMBER() OVER(PARTITION by Firstname, empID ORDER BY Firstname)
AS duplicateRecCount
FROM dbo.tblEmployee
)
--Now Delete Duplicate Records
DELETE FROM tblEmployee
WHERE duplicateRecCount > 1
But I don't know where I went wrong it is saying
Invalid column name
duplicateRecCount
Can someone help me?