springboot集成Jasypt实现配置文件启动时自动解密-ENC
2026/1/8 1:36:25
第N高的薪水https://leetcode.cn/problems/nth-highest-salary/
表:Employee
| Column Name | Type |
| id | int |
| salary | int |
id 是该表的主键(列中的值互不相同)。该表的每一行都包含有关员工工资的信息。
编写一个解决方案查询Employee表中第n高的不同工资。如果少于n个不同工资,查询结果应该为null。
示例 1:
输入:Employee table: +----+--------+ | id | salary | +----+--------+ | 1 | 100 | | 2 | 200 | | 3 | 300 | +----+--------+ n = 2输出:+------------------------+ | getNthHighestSalary(2) | +------------------------+ | 200 | +------------------------+
示例 2:
输入:Employee 表: +----+--------+ | id | salary | +----+--------+ | 1 | 100 | +----+--------+ n = 2输出:+------------------------+ | getNthHighestSalary(2) | +------------------------+ | null | +------------------------+
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT BEGIN DEClARE offset_num INT; set offset_num = N - 1; RETURN ( # Write your MySQL query statement below. select( select distinct salary from Employee order by salary desc limit offset_num,1 --不支持直接 N-1 ) ); END