0
What is the query to find 3rd highest salary
2 Answers
+ 7
https://stackoverflow.com/questions/20690629/sql-query-to-find-third-highest-salary-in-company
"The most simple way that should work in any database is to do following:
SELECT * FROM `employee` ORDER BY `salary` DESC LIMIT 1 OFFSET 2;
Which orders employees by salary and then tells db to return a single result (1 in LIMIT) counting from third row in result set (2 in OFFSET). It may be OFFSET 3 if your DB counts result rows from 1 and not from 0.
This example should work in MySQL and PostgreSQL."
"You can get the third highest salary by using limit , by using TOP keyword and sub-query
TOPÂ keyword
SELECT TOP 1 salary FROM (SELECT TOP 3 salary FROM Table_Name ORDER BY salary DESC) AS Comp ORDER BY salary ASC
limit
SELECT salary FROM Table_Name ORDER BY salary DESC LIMIT 2, 1
by subquery
SELECT salary FROM (SELECT salary FROM Table_Name ORDER BY salary DESC LIMIT 3) AS Comp ORDER BY salary LIMIT 1;
I think anyone of these help you."
that's what is on the site. you can follow the link for more info
+ 2
SELECT salary FROM someTable ORDER BY salary DESC LIMIT 1 OFSET 2;