SELECT MAX(Salary) AS SecondHighestSalary FROM Employee WHERE Salary < (SELECT MAX(Salary) FROM Employee)
At first I tried this:
SELECT Salary AS SecondHighestSalary FROM Employee LIMIT 2,1
but not work. Anyone can fix it?
Well when you say LIMIT 2,1 you basically tell SQL that you want 1 row from offset 2, which means you want row number 3 from the results. I don't think that is what you want....
Here is how I did it:
SELECT IF( COUNT( A.Salary ) > 1, MIN( A.Salary ), NULL ) as SecondHighestSalary FROM (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 0,2) A