-4

To find highest salary from db we use max in query.

How to get 2nd highest salary from db. can any one suggest the sq query

Matt
  • 14,007
  • 25
  • 88
  • 136
  • 1
    did you try to google it? there are plenty of results for [sql select second highest value](http://stackoverflow.com/questions/32100/what-is-the-simplest-sql-query-to-find-the-second-largest-value) – SomeJavaGuy Aug 19 '15 at 14:44
  • Whats your data structure? Tables? Sample data? – Matt Aug 19 '15 at 14:45

2 Answers2

1

This should help:

SELECT max(salary) 
FROM mytable
WHERE salary < (
   SELECT max(salary) FROM mytable
)
Jacobian
  • 9,082
  • 25
  • 109
  • 208
1

Far to many ways to achieve this.

SELECT Salary 
FROM Salarytable 
ORDER BY Salary DESC
LIMIT 1,1
Matt
  • 14,007
  • 25
  • 88
  • 136