title: Return distinct columns, ordered by count of duplicates
body: <p>Here are my three relevant sql tables with their relevant properties:</p>
  
  <ol>
  <li>OrderType with property <code>ID</code> </li>
  <li>RestaurantVisit, with property <code>OrderTypeID</code> and <code>RestaurantID</code></li>
  <li>Restaurant, with property <code>ID</code></li>
  </ol>
  
  <p>When given an Order Type (eg Drink, Side, Entree), I need to return all of the restaurants that have ordered that order type before, ordered by which restaurant has the <strong>most</strong> orders of that type.</p>
  
  <p>For example, given type <code>side</code>, I return Restaurants <code>r1, r2, r3</code>, where r1 is the restaurant that has the <strong>most</strong> orders of <code>side</code> out of all the restaurants, <code>r2</code> is the one with second most, etc.</p>
  
  <p>This is what I have so far (remember, I'm given an OrderTypeID already):</p>
  
  <pre><code>SELECT DISTINCT r.ID
  FROM Restaurant r
    JOIN RestaurantVisit rv
      ON rv.OrderTypeID = ?
  WHERE rv.ID = r.ID
  </code></pre>
  
  <p>This currently works to return all of the restaurants that have ever received an order of the given type.  What I need to do now is order these by the restaurants that have the most of orders of the given type.</p>
  
  <p>What I'm thinking is to add something like this somewhere, but I'm not at all sure:</p>
  
  <p><code>ORDER BY COUNT(rv.OrderTypeID = ?)</code> </p>
  
  <p>Anyone have any ideas?  Thanks!</p>