sql group/order by question

cfleck

tired
Some web references seem to insist that this is possible, but I can't make it happen.

I have a table of names. What I want to do is return a list of those names with the number of times those names show up ordered by that number.

I would think the following would do what I want...

PHP:
SELECT name, count(name) from testdata group by name order by count(name);

But, alas, this is not the case. I get an "Invalid use of group function" error.

Can someone help me out here?
 
what you need is this

Code:
select name,count(name) as c from testdata group by name order by c

hope it helps
 
Back
Top