SQL> select rownum,month,sell from sale where rownum=2;(1以上都查不到记录)没有查到记录 SQL> select rownum,month,sell from sale where rownum>5; (由于rownum是一个总是从1开始的伪列,Oracle 认为这种条件不成立,查不到记录) 没有查到记录 luckysxn(风花雪) 同学请注意rownum 用法
select * from (select t.*,rownum id from table) where id between 10 to 20
可以用 select * from tab where rownum <= (3+1)*20 minus select * from tab where rownum <= 3*20+1; 但是速度不能保证。另外,我的疑问是如果你想达到这样的结果,为何 不在表结构中加上比如象行id这样的字段,就容易 做了。
luckysxn(风花雪) 的是错的,rownum不能那样用 select * from (select t.*,rownum id from table t) where id between 10 to 20 上面少了一个t
select * from tab where rownum <= (3+1)*20 minus select * from tab where rownum <= 3*20+1; 的速度没有 select * from (select t.*,rownum id from table t) where id between 10 to 20 快
我再问一下: 我这样写行不行: select * from (select t.*,rownum id from table t where "我所需的条件") where id between 10 to 20
我再问一下: 我这样写行不行: select * from (select t.*,rownum id from table t where "我所需的条件" order by "我所需的字段") where id between 10 to 20
SQL> select rownum,month,sell from sale where rownum>5;
(由于rownum是一个总是从1开始的伪列,Oracle 认为这种条件不成立,查不到记录)
没有查到记录 luckysxn(风花雪) 同学请注意rownum 用法
where id between 10 to 20
select * from tab where rownum <= (3+1)*20
minus
select * from tab where rownum <= 3*20+1;
但是速度不能保证。另外,我的疑问是如果你想达到这样的结果,为何
不在表结构中加上比如象行id这样的字段,就容易
做了。
select * from (select t.*,rownum id from table t)
where id between 10 to 20
上面少了一个t
minus
select * from tab where rownum <= 3*20+1;
的速度没有
select * from (select t.*,rownum id from table t)
where id between 10 to 20
快
我这样写行不行:
select * from (select t.*,rownum id from table t where "我所需的条件")
where id between 10 to 20
我这样写行不行:
select * from (select t.*,rownum id from table t where "我所需的条件" order by "我所需的字段")
where id between 10 to 20
应该是 between 10 and 20 吧?