First, find the n-th high salary
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
set N=N-1;
RETURN (
select distinct(salary) from employee order by salary desc limit N,1
);
END
Because the page limit from 0 to take the first one is 0 (this is still do not understand)
limit offset:\
* from limit Table 2 SELECT 1 offset;
// the article 1 (not including) the start of data extracted two data, with the latter two is to limit the data is read from the offset back to article 1, i.e., read the first 2,3 bar
Second, look for the second-highest salary
select max(Salary) as SecondHighestSalary
from employee
where
salary<(select max(salary) from employee)