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

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

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

可以使谓词Top n来定实现这个需求。例如:

select top 10 from tableName order by colName;

select top 20 from tableName order by colName;

select top 30 from tableName order by colName;

MYSQL

查询语句+LIMIT+10

取查询记录的前十条。

如:SELECT

FROM

Test

LIMIT

10

查询语句+LIMIT+2,10

取查询语句,从第二条记录,取十条记录。

如:SELECT

FROM

Test

LIMIT

2,10

select name sex from piva_orders a,piva_orders b where aname!=bname limit 10;

朋友,这样试试。

以上就是关于数据库查询语句问题,查询数量前十的信息数,进行排序全部的内容,包括:数据库查询语句问题,查询数量前十的信息数,进行排序、要取出数据库中按某字段排序后的前10,20,30条数据要怎么做、常用几种数据库,取前10条记录的sql语句写法等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/9610831.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-30
下一篇 2023-04-30

发表评论

登录后才能评论

评论列表(0条)

保存