数据库查询语句问题,查询数量前十的信息数,进行排序

来源:百度知道 编辑:UC知道 时间:2024/07/01 06:41:41
先看表pe_soft

id=softid
录入=inputer
频道=channelid

id 录入 频道
1 周 2
2 周 30
3 王 2
4 周 2
5 王 30

我要查询录入者共在频道2录入多少条信息,并且排序
就是没个录入者都要查询出他录入了多少条信息,按数量排序.

本人初学,望高手赐教.
请写出查询语句......非常感谢,我在线等.

要一次查询出来,以录入者的录入数量排序.
查询出排行前十的录入者,列出录入数量.

SELECT top 10 录入,COUNT(*)
FROM pe_soft
WHERE 频道='2'
GROUP BY 录入
ORDER BY COUNT(*)

select channelid as 频道,count(channelid) as 小计 from pe_soft where channelid = '2' group by channelid order by 2

select inputer as 录入,channelid as 频道,count(channelid) as 小计 from group by inputer,channelid order by 3

select top 10 inputer as 录入,count(channelid) as 小计 from pe_soft where channelid = '2' group by inputer order by 2

SELECT 录入,COUNT(*)
FROM pe_soft
WHERE 频道='2' (如果数据类型为数字型不要单引号)
GROUP BY 录入
ORDER BY COUNT(*)

select top 10 inputer as 录入,
count(channelid) as 录入次数
from pe_soft
where channelid = '2'
group by inputer
order by 2

运行通过
试试

select top 10 count('录入')as num from pe_soft group by '频道' order by num desc
这个我已经测试过了 没问题 是倒序排列 要升序 去掉最后的desc就好了

num是我给count('录入')起的伪列名

s