0

Hey there,
I need help with writing a query so I figured I'd ask here. Let me thank you in advance for your answer.

I need to see how often a value inside a certain column appears in a table. Say for example I have a table Person, that has a field name.

I want to know top five most frequently occuring names, along with the number indicating how often each appears.

Thank you.

2
Contributors
4
Replies
19
Views
4 Years
Discussion Span
Last Post by bibiki
0

thanks for the help pritaeas,

this is what I am trying:

select name, count(name) frequency from (select name from person) order by frequency

and I am expeting:

someName|12
anOtName|7

but it is not working at all. hmm. can you please give some more hints?

0
SELECT `name`, COUNT(`name`) AS `frequency` 
FROM `person` 
GROUP BY `name` 
ORDER BY `frequency` DESC

This is tested on MySQL 5.5

0

Hey pritaeas,
thank you very much for your help. sorry for late reply. That was helpful enought to get me through the block. thanks again.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.