Home  >  Article  >  Database  >  Oracle用with语句查询第N到第M条记录

Oracle用with语句查询第N到第M条记录

WBOY
WBOYOriginal
2016-06-07 17:06:34887browse

我们经常要访问数据集的某一个中间部分,例如第10到第20条记录,Oracle中有一个很好语句来实现,那就是with。以下是使用的例子:

我们经常要访问数据集的某一个中间部分,例如第10到第20条记录,,Oracle中有一个很好语句来实现,那就是with。以下是使用的例子:

with partdata as (select rownum rowno,t.* from  table1 t where t.id>200407160000)

select * from partdata where rowno between 10 and 20

当然还有别的方法,但我目前测试这种方法的速度最快。以上代码在Oracle 9i中测试通过。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn