title: Delete duplicate rows leaving recent 10 using mysql
body: <p>I have a table containing multiple fields but important fields (to be used in query) are</p>
  <p><em><strong>phone_number varchar(20),
  entry_date datetime</strong></em></p>
  <p>This table contains records in millions and each phone_number have multiple entries. I want to delete phone_numbers having multiple entries but want to keep last 10 for each phone_number</p>
  <p><strong>Example:</strong></p>
  <pre><code>SELECT phone_number,COUNT(*) 
  FROM test_table 
  GROUP BY phone_number 
  HAVING COUNT(*) &gt; 10 
  ORDER BY COUNT(*) DESC;
  </code></pre>
  <p><strong>Result:</strong></p>
  <p><a href="https://i.stack.imgur.com/DSZnD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DSZnD.png" alt="enter image description here" /></a></p>
  <p><strong>Requirement:</strong></p>
  <p>I want a query that reduce all these counts to 10 but those must be recent 10 records for each phone_number</p>