title: Delete Duplicate rows from table which have same Id
body: <p>I have a table Emp which have records like this</p>
  
  <pre><code>Id     Name
  1      A
  2      B
  3      C
  1      A
  1      A
  2      B
  3      C
  </code></pre>
  
  <p>Now I want to delete the duplicate rows from the table 
  I am using this query to select or count number of duplicate records</p>
  
  <pre><code>SELECT NameCol, COUNT(*) as TotalCount FROM TestTable 
  GROUP BY NameCol HAVING COUNT(*) &gt; 1 
  ORDER BY COUNT(*) DESC
  </code></pre>
  
  <p>and what query should i write to delete the duplicate rows from table.</p>
  
  <p>if I write this query to delete the duplicate records then it is giving a <code>(0) row Affected</code> result.</p>
  
  <pre><code>`DELETE FROM TestTable 
      WHERE ID NOT IN ( SELECT MAX(ID) FROM 
                                       TestTable 
                                       GROUP BY NameCol
                      )`
  </code></pre>