title: Deleting duplicate record in SQL Server
body: <p>I have written a query to remove duplicate records from a table </p>
  
  <pre><code>;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 &gt; 1 
  </code></pre>
  
  <p>But I don't know where I went wrong it is saying </p>
  
  <blockquote>
    <p>Invalid column name <code>duplicateRecCount</code></p>
  </blockquote>
  
  <p>Can someone help me?</p>