如何根据标记选择表格中的前5名学生

问题描述 投票:0回答:1
cursor.execute("select name,marks from student order by marks desc limit 5")

cx_Oracle.DatabaseError:ORA-00933:SQL命令未正确结束

如何解决此错误?还有什么其他方法可以重述查询?此查询有什么问题?

sql python-3.x
1个回答
0
投票

limit不是Oracle SQL语法的一部分。您可以在此类用例中使用fetch first

cursor.execute("select name, marks from student order by marks desc fetch first 5 rows only")
© www.soinside.com 2019 - 2024. All rights reserved.