order by cont ->order by count(*) select count(*) as cont,ctt_id from tmp GROUP BY ctt_id order by count(*) desc limit 0,20