select author,count(*) as record from hfluntan order by record desc group by author limit 0,20

水墨画 2002-08-23 03:23:20
各位帮忙看看

select author,count(*) as record from hfluntan order by record desc group by author limit 0,20

这句话正确吗?

这个如何排序呀,我想按每个人的多少来排序呀,多的排前面呀

假如:有个表的字段如下:

记录号 字段名1 字段名2
1 A tt
2 B ww
3 A ss
4 C dd
5 C ss
6 A ee

我想显示的结果是这样的

字段名1 count
A 3
C 2
B 1



请大家帮忙呀,多谢!

...全文
101 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
supsuccess 2002-08-23
  • 打赏
  • 举报
回复
select author,count(*) as record
from hfluntan
group by author
order by record desc
limit 0,20
ralpher2017 2002-08-23
  • 打赏
  • 举报
回复
up
dejoy 2002-08-23
  • 打赏
  • 举报
回复
把order by record desc放到 group by author 后就可以了.
group by author order by record desc limit 0,20

dejoy 2002-08-23
  • 打赏
  • 举报
回复

select fd1,count(*) as rec from m group by fd1 order by rec DESC
shuixin13 2002-08-23
  • 打赏
  • 举报
回复
select author,count(*)as record from hfluntan group by author order by record desc

56,687

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧