select *, count(distinct name) from table group by name
http://blog.sina.com.cn/s/blog_7e7249c301012l98.html