title: Rails (or maybe SQL): Finding and deleting duplicate AR objects
body: <p>ActiveRecord objects of the class 'Location' (representing the db-table Locations) have the attributes 'url', 'lat' (latitude) and 'lng' (longitude).</p>
  
  <p>Lat-lng-combinations on this model should be unique. The problem is, that there are a lot of Location-objects in the database having duplicate lat-lng-combinations. </p>
  
  <p>I need help in doing the following</p>
  
  <ol>
  <li>Find objects that share the same
  lat-lng-combination.</li>
  <li>If the 'url' attribute of the object
  isn't empty, keep this object and delete the
  other duplicates. Otherwise just choose the
  oldest object (by checking the attribute
  'created_at') and delete the other duplicates.</li>
  </ol>
  
  <p>As this is a one-time-operation, solutions in SQL (MySQL 5.1 compatible) are welcome too. </p>