SQL查詢語句怎樣限定返回結果集的行數?
1、創建測試表,create table test_rows(id number, value varchar(200));
2、插入測試數據,
insert into test_rows
select level, 'val_'||level from dual
connect by level
commit;
3、查詢表中記錄數,總共有999條,
4、編寫SQL,返回最小的10條記錄,
select * from (select t.*, row_number() over(order by id) rn from test_rows t ) where rn=10;