在刚才的基础上。
insert into look values (2,'a',100);
insert into look values (3,'a',100);
insert into look values (4,'a',100);
insert into look values (5,'a',100);
insert into look values (6,'a',100);
insert into look values (7,'a',100);
insert into look values (8,'a',100);
insert into look values (9,'a',100);
insert into look values (10,'a',100);
insert into look values (11,'a',100);
insert into look values (12,'a',100);
insert into look values (13,'a',100);
insert into look values (14,'a',100);
insert into look values (15,'a',100);
insert into look values (16,'a',100);
insert into look values (17,'a',100);
insert into look values (18,'a',100);
insert into look values (19,'a',100);
insert into look values (20,'a',100);
SELECT * FROM look ORDER BY id DESC FETCH FIRST 3 ROWS ONLY;
SQL> SELECT * FROM look ORDER BY id DESC FETCH FIRST 3 ROWS ONLY;
ID NAME MONEY
---------- ---------- ----------
20 a 100
19 a 100
18 a 100
排名前三的
SQL> SELECT * FROM look ORDER BY id DESC FETCH FIRST 10 PERCENT ROWS ONLY;
ID NAME MONEY
---------- ---------- ----------
20 a 100
19 a 100
排名前10%的
SQL> SELECT * FROM look ORDER BY id DESC OFFSET 5 ROWS FETCH NEXT 5 ROWS ONLY;
ID NAME MONEY
---------- ---------- ----------
15 a 100
14 a 100
13 a 100
12 a 100
11 a 100
忽略前5条记录并会显示表的下5条记录:
SELECT * FROM look ORDER BY id FETCH FIRST 5 PERCENT ROWS WITH TIES;
ID NAME MONEY
---------- ---------- ----------
1 a 100
分享标题:12CSQL-TOP
新闻来源:
http://shouzuofang.com/article/iejeip.html