Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
SELECT salary FROM employee ORDER BY salary DESC LIMIT n-1,1
此查询用于查找第 n 个最高薪水。如果可能的话,用例子解释一下?
例子
SELECT * FROM tbl LIMIT 5,10; `# Retrieve rows 6-15`
5- 开始索引
5
10- 起始索引的记录数
10
see here
SELECT salary- 仅选择工资列 FROM employee- 对员工表执行上述操作 ORDER BY salary DESC- 按工资降序对结果进行排序 LIMIT n-1,1- 显示从第 (n-1)个索引开始的结果并仅显示 1 行。
SELECT salary
FROM employee
ORDER BY salary DESC
LIMIT n-1,1
注意 - 索引从 0 开始,这就是为什么(n-1)使用而不是n.
(n-1)
n.