对"rownum"的澄清 [英] Clarification on "rownum"

查看:58
本文介绍了对"rownum"的澄清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表Table1

I have a table Table1



Name     Date
A 01-jun-2010
B 03-dec-2010
C 12-may-2010

当我使用以下查询查询该表时

When i query this table with the following query

select * from table1 where rownum=1

我的输出为


Name       Date
A 01-jun-2010

但是以同样的方式,当我使用以下查询时,我没有得到任何输出.

But in the same way when i use the following queries i do not get any output.

select * from table1 where rownum=2
select * from table1 where rownum=3

请有人给我指导,为什么它会那样工作,以及如何使用rownum.

Someone please give me guidance why it works like that, and how to use the rownum.

推荐答案

Tom has an answer for many Oracle related questions

简而言之,在应用where子句之后和应用order by子句之前,rownum可用.

In short, rownum is available after the where clause has been applied and before the order by clause is applied.

在RowNum = 2的情况下,where子句中的谓词将永远不会为true,因为RowNum从1开始,并且只有在找到与该谓词匹配的记录时才会增加.

In the case of RowNum=2, the predicate in the where clause will never evaluate to true as RowNum starts at 1 and only increases if records matching the predicate can be found.

这篇关于对"rownum"的澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆