count top 10 most occuring values in a column in mysql

前端 未结 4 1155
栀梦
栀梦 2020-12-01 15:39

I have a column in mysql table that has the the data type INT(11).

How can I search to get the top 10 most occurring values in this column?

4条回答
  •  北海茫月
    2020-12-01 15:51

    Try the following code

    SELECT colname, COUNT(*) AS cnt
    FROM tablename
    GROUP BY colname
    ORDER BY cnt DESC
    LIMIT 10
    

提交回复
热议问题