Although this thread is already resolved, I have a couple of notes regarding the SQL queries and the resolving query, in this case.
First, aggregate function (SUM, COUNT, AVG etc.) columns are easier to handle in non-SQL code when given alias names using AS and some name. Compare these two pieces of PHP, for example:
$total_friends = $row['COUNT(*)'];
$total_friends = $row['total_friends'];
The latter one is much clearer to the coder than the first one.
Second, ORDER BY accepts alias names since ordering is done after the columns have been selected. And even if for some reason it wouldn't accept an alias, there is no need to use single quotes around the column name.
So, I'd change the query to this, which is much clearer to me:
SELECT friend, COUNT(*) AS total_friends
FROM friends
GROUP BY friend
ORDER BY total_friends DESC