Is there a way to order by the result of a COUNT(*) query?
For example:
$result = mysql_query("SELECT ref_page, COUNT(*) FROM unique_views GROUP BY ref_page");
$myrow = mysql_fetch_array($result);
In the above query I want to order the results by the result of the COUNT(*) e.g.
$result = mysql_query("SELECT ref_page, COUNT(*) FROM unique_views GROUP BY ref_page ORDER BY COUNT(*)");
$myrow = mysql_fetch_array($result);
Is there a way to do this?
Thanks in advance for any help.