clwn.net
当前位置:首页 >> sql排序取前10条 >>

sql排序取前10条

with a as( select *,row_number() over(order by ColA) rn from tabA) select * from a where rn>=10 and rn

1.limit关键字是mysql中的,top关键字是ms sqlserver中的,pl/sql是oracle的客户端工具,这两个关键字在这里不适用。 2.select rownum,a.* from (select * from test order by id desc) a where rownum

直接用order by 和top结合的语句就可以实现。 创建表及插入数据: create table test(id int,name varchar(20))insert into test values (1,'百度知道团长')insert into test values (3,'du小智')insert into test values (4,'du小佑')insert in...

oracle: select * from tab where rownum

1. Oracle数据库 SELECT * FROM TABLENAME WHERE ROWNUM

一楼逻辑有问题,这个SQL是先在表中取出前10行,在进行排序; 应该先对表排序,在取出前10行; select * from a (select * from table order by xxx) a where rownum

MYSQL中查询表中按字段降序排列的前N条记录模式: SELECT 字段名[ , 字段名...] FROM 表名 WHERE 条件 LIMIT 数量 ORDER BY 字段名 DESC 例如: select id,name,email from test where age < 19 limit 5 order by id desc;上面例子从test表查询...

--SQL Server 2000 select top (5) * from ( select top 15 * from 表 order by 排序列 desc ) as a order by 排序列 desc --SQL Server 2005,2008,2008R2,2012通用方法 select * from ( select *,row_number() over (order by 排序列 desc) as ...

select top 10 left(content,15)+'......' from tb order by time

很简单,首先你先排好序在取前十条记录SELECT * FROM (SELECT o.* FROM T_Operator o ORDER BY createtime) WHERE ROWNUM

网站首页 | 网站地图
All rights reserved Powered by www.clwn.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com