title: Select all distinct values where datestamp is in the last 24 hours and order by total rows ASC
body: <p>I have a query I am trying to formulate, but it keeps giving me unexpected results.</p>
  
  <p>What I need to do is:</p>
  
  <p>select all distinct values from my table where the unix timestamp is >= the last 24 hours, then order these results by which one has the highest amount of entries.</p>
  
  <p>I have managed the time part:</p>
  
  <pre><code>SELECT DISTINCT(column_name) as myValue from table_name WHERE time_column &gt;= unix_timestamp(CURRENT_TIMESTAMP, INTERVAL 1 DAY)
  </code></pre>
  
  <p>This works as expected. Then I was just going to use PHP to sort through the results etc etc, however I wish to use the power of SQL on this one.</p>
  
  <p>Any ideas how I can extend the above query to encapsulate counting the amount of distinct column_name values? Also to then sort this in order dependent on how many values are in each one?</p>
  
  <p>So essentially I want to get my results like so :</p>
  
  <pre><code>a unique ID  | highest amount
  a unique ID  | second highest amount
  a unique ID  | lowest amount
  </code></pre>