At 12:40 PM -0500 6/3/99, Darren Sweeney wrote:
>Hi
>
>I have a table which has a simple field: name
>
>This field may contain the same name many times.
>
>What i need to do is to count how many distinct names there are and how
>many times their name is listed to produce something like:
>
>name | count
>==========
>john | 10
>Ted | 15
>Pat | 15
>
>etc. etc.
>
>I am struggling to be able to find the correct select formula ... i think
>i am looking too deeply as i am sure it is quite simple ...
>
>I am trying:
>
>select distinct name as name, count(distinct name) as count from tablename;
>
>Thanks for any help
>
>Darren
The MySQL tutorial in the manual has examples that show how to do what
you want. The second, third, and fourth example in the "Counting Rows" section
are all instances of your type of query:
http://www.mysql.com/Manual_chapter/manual_Tutorial.html#Counting_rows
--
Paul DuBois, paul@stripped
Northern League Chronicles: http://www.snake.net/nl/