-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,906
  • 27
  • 99
  • 149
  • 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
  • 10,122
  • 29
  • 128
  • 221
1

Far to many ways to achieve this.

SELECT Salary 
FROM Salarytable 
ORDER BY Salary DESC
LIMIT 1,1
Matt
  • 14,906
  • 27
  • 99
  • 149