title: MySQL "ORDER BY" the amount of rows with the same value for a certain column?
body: <p>I have a table called <code>trends_points</code>, this table has the following columns:</p>
  
  <ul>
  <li>id (the unique id of the row)</li>
  <li>userId (the id of the user that has entered this in the table)</li>
  <li>term (a word)</li>
  <li>time (a unix timestamp)</li>
  </ul>
  
  <p>Now, I'm trying to run a query on this table which will get the rows in a specific time frame ordered by how many times the column <code>term</code> appears in the table during the specific timeframe...So for example if the table has the following rows:</p>
  
  <pre><code>id | userId | term        | time
  ------------------------------------
  1    28       new year      1262231638
  2    37       new year      1262231658
  3    1        christmas     1262231666
  4    34       new year      1262231665
  5    12       christmas     1262231667
  6    52       twitter       1262231669
  </code></pre>
  
  <p>I'd like the rows to come out ordered like this:</p>
  
  <pre><code>new year
  christmas
  twitter
  </code></pre>
  
  <p>This is because "new year" exists three times in the timeframe, "christmas" exists twice and "twitter" is only in one row.</p>
  
  <p>So far I've asummed it's a simple WHERE for the specific timeframe part of the query and a GROUP BY to stop the same term from coming up twice in the list.</p>
  
  <p>This makes the following query:</p>
  
  <pre><code>SELECT * 
    FROM `trends_points` 
   WHERE ( time &gt;= &lt;time-period_start&gt; 
    AND time &lt;= &lt;time-period_end&gt; ) 
  GROUP BY `term`
  </code></pre>
  
  <p>Does anyone know how I'd do the final part of the query? (Ordering the query's results by how many rows contain the same "term" column value..).</p>