count top 10 most occuring values in a column in mysql
SELECT col, count(*)
FROM tablethingie
GROUP BY col
ORDER BY count(*) DESC
LIMIT 10
Try the following code
SELECT colname, COUNT(*) AS cnt
FROM tablename
GROUP BY colname
ORDER BY cnt DESC
LIMIT 10
TOP is a keyword which is not supported in MySQL, it is in MSSQL though.
This following query should do what you want (untested, but the idea should become clear):
SELECT column, COUNT(*) AS matches
FROM table
GROUP BY column
ORDER BY matches DESC
LIMIT 10
Try:
SELECT ColName, Count(1) AS occurances
FROM
table
GROUP BY
ColName
ORDER BY
occurances DESC
LIMIT
10