Jecki Jecki - 1 month ago 12
MySQL Question

SELECT Count(userid) adjusment

My statement shows result as

userid Count(userid)

SELECT userid, COUNT( userid )
FROM friends
GROUP BY userid
ORDER BY `COUNT(userid)` DESC
LIMIT 0 , 30


I have 1 more column "level" in friends table need to add it in my result

how tp adjust my statement

So my result appear like

userid Count(userid) level

Answer

You may try :

   SELECT userid, COUNT( userid ) AS cnt, level
   FROM friends
   GROUP BY userid
   ORDER BY cnt DESC 
   LIMIT 30