Home > Backend Development > PHP Tutorial > 分组统计功能

分组统计功能

WBOY
Release: 2016-06-23 13:37:58
Original
1239 people have browsed it

username 
     小明
     小黄
     小明
     小红
     小红
     小红
     小花
希望得到的结果是频次前3的名字    例如    第一:小红     3次
                                                                          第二: 小明    2次
                                                                          第三: 小花、小黄   1次


万分感谢!!


回复讨论(解决方案)

select username, count(*) as cnt fron tbl_name group by username order by cnt desc
Copy after login

求楼上大神帮忙写下输出的格式谢谢,新手求助

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template