【发布时间】:2023-03-05 19:04:01
【问题描述】:
我想通过首先将结果集限制为 n 个最高薪水,然后将结果集反转并将其限制为 1,从而获得表中第 n 个最高薪水。
我使用了这个导致错误的查询:-
select *
from salaries
where emp_no=(select * from salaries order by salary desc limit 2) order by salary asc limit 1;
错误表明子查询返回多行。
【问题讨论】:
-
提示:切勿使用
SELECT * -
像这样使用“从工资中选择 colname1,colname2 where emp_no=(select
-
似乎是一个简单问题的复杂解决方案。假设你想得到第 5 名的最高薪水,查询薪水列,按 asc limit 1 offset 4 排序