MySQL - Selecting the top occuring entries
Posted
by RC
on Stack Overflow
See other posts from Stack Overflow
or by RC
Published on 2010-04-03T10:50:02Z
Indexed on
2010/04/03
10:53 UTC
Read the original article
Hit count: 195
Hi, Should be a simple one.
Database is mydb. One of the columns is mydata.
What SELECT query do I need in order to select the top 3 occuring results from mydata, but sorted alphabetically?
For example, if my data is this:
mydata
======
kilo (x 1 occurrence)
lima (x 9 occurrences)
golf (x 5 occurrences)
echo (x 9 occurrences)
zulu (x 8 occurrences)
How do I get it to return "echo, lima, zulu", which are the top three frequently occurring entries sorted alphabetically? Thanks!
EDIT: Just to add, they need to be distinct entries. Thanks!
© Stack Overflow or respective owner