title: Group, count, having, and order by in Rails
body: <p>I have a table: <code>people</code> with a column named: <code>age</code>.</p>
  
  <p>How can I get a count of the people with each age, ordered from oldest to youngest, filtered by ages with at least 2 people in it?</p>
  
  <p><strong>How I would write it in raw SQL:</strong></p>
  
  <pre><code>SELECT
    COUNT(1) AS people_count,
    age
  FROM people
  GROUP BY age
  HAVING people_count &gt; 1
  ORDER BY age DESC
  </code></pre>
  
  <p><strong>In Rails (I'm not sure how to do it):</strong></p>
  
  <p><code>Person.group(:age).count</code> will get me the counts by <code>age</code>, but I can't figure out how to order it descendingly by age, or add the <code>having</code> clause.</p>