时间:2021-07-01 10:21:17 帮助过:24人阅读
查询员工表中薪水从高到低排序的第5~9条记录
============================================================
SELECT *
FROM (SELECT e.*,rownum rn FROM (SELECT * FROM employee ORDER BY sal DESC) e)
WHERE rn>=5 AND rn<=9;
SELECT *
FROM (SELECT E.*, ROWNUM RN
FROM (SELECT * FROM EMPLOYEE ORDER BY SAL DESC) E WHERE ROWNUM<=9 )
WHERE RN >= 5;
--mysql
SELECT * FROM EMPLOYEE ORDER BY SAL DESC LIMIT 4 , 5
该sql语句的意思是,从第几行开始,然后取多少行,MySQL中第一行的下标是0
数据库排序
标签:limit select 记录 -- rownum desc mysq 数据库 多少