How do I execute this query in MYSQL?
Translations
Englishالعربية
български
català
中文
čeština
dansk
Nederlands
eesti
suomi
français
Deutsch
Ελληνικά
עברית
हिंदी
magyar
Bahasa Indonesia
italiano
日本語
한국어
latviešu
lietuvių
norsk
polski
Português
română
русский
slovenčina
slovenski
español
svenska
ไทย
Türkçe
українська
Tiếng Việt
Suppose I have a column with words:
orange
grape
orange
orange
apple
orange
grape
banana
How do I execute a query to get the top 10 words, as well as their count?
This question and answers originated from www.stackoverflow.com
Question by TIMEX (3/15/2010 7:28:53 AM)
Answer |
SELECT word, COUNT(*) word_cnt
FROM your_table
GROUP BY word
ORDER BY COUNT(*) DESC
LIMIT 10
The GROUP BY groups by values of word, the ORDER BY COUNT(*) DESC gets you the rows with highest count first, and the LIMIT 10 returns the first 10 rows only.
Answer by Peter Lang
Find More Answers