title: Delete duplicate rows using custom logic
body: <p>I'm stuck to find a way to remove some duplicate rows in a MySQL database using some custom logic.</p>
  
  <p>Actual datas :</p>
  
  <pre><code>id  name    population
  1   CityA   1000
  2   CityA   50
  3   CityA   0
  4   CityB   0
  5   CityB   0
  6   CityC   10
  </code></pre>
  
  <p>Desired result :</p>
  
  <pre><code>id  name    population
  1   CityA   1000
  4   CityB   0
  6   CityC   10
  </code></pre>
  
  <p>I tried this query without success (it has deleted all rows for a city if all populations are equal to <code>0</code>, like in the CityB example):</p>
  
  <pre><code>DELETE t 
  FROM table AS t, table AS t2
  WHERE t.id != t2.id
  AND t.population &lt;= t2.population
  </code></pre>
  
  <p>Could any super hero solve this super problem ?</p>
  
  <p><strong>[EDIT] The working solution</strong> : <a href="http://sqlfiddle.com/#!9/ea3e3/2" rel="nofollow noreferrer">http://sqlfiddle.com/#!9/ea3e3/2</a></p>