sql group/order by question


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...

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?


Partially Insane
what you need is this

select name,count(name) as c from testdata group by name order by c
hope it helps