limit与offset的用法
查找入职员工时间排名倒数第三的员工所有信息
http://www.nowcoder.com/questionTerminal/ec1ca44c62c14ceb990c3c40def1ec6c
SELECT *
FROM employees
WHERE hire_date = (
SELECT DISTINCT hire_date
FROM employees
ORDER BY hire_date DESC -- 倒序
LIMIT 1 OFFSET 2 -- 去掉排名倒数第一第二的时间,取倒数第三
);
limit与offset的用法:
(1)limit y offset x 表示: 跳过 x 条数据,读取 y 条数据
(2)limit y 表示: 读取 y 条数据
(3)limit x, y 表示: 跳过 x 条数据,读取 y 条数据