bzszp(SongZip): 我照你的方法做了,select * from tablel where rownum < 11; 但显示: 未选定行 不知为什么?
select count(*) from tablel; 看有没有数据
bzszp(SongZip): 行了! 但如果我想选择表中第10到20条的数据,该怎么写呢?
select * from tablel where rownum < 21 and rownum >10;
bzszp(SongZip): 我照你的方法做了,select * from tablel where rownum < 21 and rownum >10; 但显示: 未选定行 不知为什么?似乎不能用">"号.
这样 select * from tablel where rownum < 21 minus select * from tablel where rownum < 11;
但似乎不能对minus的结果排序. 如果要做的话,该怎样做呢?
这样 select * from tablel where rownum < 21 order by col1 minus select * from tablel where rownum < 11 order by col1;
不行啊! select * from tablel where rownum < 21 order by col1 是可以的. 但 select * from tablel where rownum < 21 order by col1 minus select * from tablel where rownum < 11 order by col1; 不行.也许minus前不能用order by. 不知怎样才能排序?
select * from (select rownum as rn ,col1 from table1 order by col1) where rn between 11 and 20;
我照你的方法做了,select * from tablel where rownum < 11; 但显示: 未选定行
不知为什么?
看有没有数据
行了!
但如果我想选择表中第10到20条的数据,该怎么写呢?
我照你的方法做了,select * from tablel where rownum < 21 and rownum >10; 但显示: 未选定行
不知为什么?似乎不能用">"号.
select * from tablel where rownum < 21
minus
select * from tablel where rownum < 11;
如果要做的话,该怎样做呢?
select * from tablel where rownum < 21 order by col1
minus
select * from tablel where rownum < 11 order by col1;
select * from tablel where rownum < 21 order by col1
是可以的.
但
select * from tablel where rownum < 21 order by col1
minus
select * from tablel where rownum < 11 order by col1;
不行.也许minus前不能用order by.
不知怎样才能排序?
(select rownum as rn ,col1 from table1
order by col1)
where rn between 11 and 20;
1. rn不能被认识.
2. rownum不能用between.
有没有其他办法呢?大侠!
where rownum <= 10
这样:
SELECT * FROM
(SELECT ROWNUM RN,COL1 FROM
(SELECT * FROM TABLE ORDER BY COL1)
)WHERE RN BETWEEN 10 AND 20
结果正确!
谢谢!