关于oracle数据库 简单语句
来源:百度知道 编辑:UC知道 时间:2024/07/08 00:01:24
就是假如表table1 里有17个数据
用什么语句能查 前0-4个
然后查5-9个
然后查10-14个
最后查15-16个
关键是第一句
sql语句怎么写啊?
用什么语句能查 前0-4个
然后查5-9个
然后查10-14个
最后查15-16个
关键是第一句
sql语句怎么写啊?
查询第m ~ n条记录
select tt.*
from (select rownum r, t.* from table t where rownum <= n) tt
where r >= m
select * from table where rownum < 5;
(可以分下组,排下序)查前面0-4条记录,千万注意 rownum 只能用< <=判断,用> >=的话可能出现不可预知的记录;
查5-9个
select * from table order by id where rownum <10
minus
select * from table order by id where rownum <5;
查10-14个话
select * from table order by id where rownum <15
minus
select * from table order by id where rownum <10;
查15-16个
select * from table order by id where rownum <17
minus
select * from table order by id where rownum <15;
SELECT *
FROM
(SELECT rownum row_num,
a.*
FROM
table1 a
WHERE rownum <= 9) -- 结束的记录编号
WHERE row_num > 4; -- 开始的记录编号