1:按name 分组查询后,并排序,
select count(*) from t_acount_addmoney t where id >161 group by name order by count(*) desc
2:按name 分组查询后,并排序,取出name ,总条数。
select t.name, count(*)from t_acount_addmoney t where id >161 group by name order by count(*) desc
3:按name 分组查询后,并排序,取出前10条记录的name ,总条数。
select * from (select t.name, count(*) from t_acount_addmoney t where id >161 group by name order by count(*) desc) where rownum <11
本文介绍了使用SQL进行数据分组及排序的具体方法,通过实际案例演示如何按名称分组并统计数量,同时展示了如何获取特定数量的记录,适用于数据库管理和数据分析人员。

被折叠的 条评论
为什么被折叠?



