请帮忙。 我有一个显示许多记录的查询。我需要找到方法,例如:在值为“A”的记录之后获取前 3 条记录
谢谢你
CREATE TABLE "TABLETEST"
(
"CUSTOMER_ID" NUMBER,
"VALUE" VARCHAR2(255 BYTE)
)
INSERT INTO TABLETEST VALUES (1, 'valueb');
INSERT INTO TABLETEST VALUES (2, 'valuec');
INSERT INTO TABLETEST VALUES (3, 'valuea');
INSERT INTO TABLETEST VALUES (4, 'valueD');
INSERT INTO TABLETEST VALUES (5, 'valueF');
INSERT INTO TABLETEST VALUES (6, 'valueY');
INSERT INTO TABLETEST VALUES (7, 'valueU');
INSERT INTO TABLETEST VALUES (8, 'valueaT');
I would like to see 3 records after record customer_id= 5
我认为你只需要
Order by..fetch
声明。
SEELCT *
FROM "TABLETEST"
WHERE "CUSTOMER_ID" > 5
ORDER BY "CUSTOMER_ID"
FETCH FIRST 3 ROWS ONLY;