创建了一个示例表并尝试过滤排名为 1 的记录,但失败了
错误
ORA-00933:SQL 命令未正确结束 00933. 00000 - “SQL 命令未正确结束” *原因:
*操作:行错误:30 列:3
CREATE TABLE exam_result (
points int,
last_name varchar(255),
first_name varchar(255) );
INSERT INTO exam_result VALUES (70, 'Emyr', 'Downes');
INSERT INTO exam_result VALUES (70, 'Dina', 'Morin');
INSERT INTO exam_result VALUES (80, 'Evie-May', 'Boyer');
INSERT INTO exam_result VALUES (60, 'Nora', 'Parkinson');
INSERT INTO exam_result VALUES (40, 'Trystan', 'Oconnor');
INSERT INTO exam_result VALUES (90, 'Eryk', 'Myers');
SELECT * FROM
(
SELECT
RANK() OVER(ORDER BY points DESC) AS ranking,
first_name,
last_name,
points
FROM exam_result
) AS a
WHERE ranking <= 1;