How to find second highest salary
Answers were Sorted based on User's Feedback
Answer / anuj
For Second Highest Salary:
select salary from tbl_name order by salary desc limit 1,1
For Third Highest Salary:
select salary from tbl_name order by salary desc limit 2,1
For Fourth Highest Salary:
select salary from tbl_name order by salary desc limit 3,1
| Is This Answer Correct ? | 13 Yes | 4 No |
Answer / shrikant patil
select max(salary) from tbl_name where salary !=(select
max(salary) from tbl_name);
| Is This Answer Correct ? | 9 Yes | 2 No |
Answer / devasundaram
SELECT salary FROM Employee_table ORDER BY salary DESC LIMIT 1,1
| Is This Answer Correct ? | 13 Yes | 10 No |
Answer / prakash.matte
if we want to make use of nested query instead of the above,
try the following
select max(column_name) from table_name where column_name =
(select
max(column_name)-(highest_salary_number_for_calculation -1)
from blocks where bid);
Example :
For second highest salary:
select max(bid) from blocks where bid = (select max(bid)-1
from blocks);
For third highest salary:
select max(bid) from blocks where bid = (select max(bid)-2
from blocks);
| Is This Answer Correct ? | 3 Yes | 2 No |
Answer / petercoloney
select salary from employee where max(salary)<(select salary from employee)
| Is This Answer Correct ? | 3 Yes | 3 No |
Answer / jose_100
SELECT SAL FROM SALARY_TABLE ORDER BY SAL DESC LIMIT 1,1;
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / vishnu
select salary from table where salary!=max(salary) order by
desc limit 1
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / nitish
SELECT sallary FROM employee ORDER BY sallary ASC limit 1,2
| Is This Answer Correct ? | 16 Yes | 22 No |
Answer / jaimin desai
Select MAX(Salary) from tbl
order by salary DESC limit 1,1
| Is This Answer Correct ? | 1 Yes | 7 No |
What is cookie in php with example?
What is http php?
What are the ways to include file in php?
Is it possible to submit a form with a dedicated button?
What are the methods useful for method overloading?
Is laravel easy to learn?
Can we extend multiple classes in php?
Suppose your Zend engine supports the mode <? ?> Then how can u configure your PHP Zend engine to support <?PHP ?> mode ?
1 Answers Rushmore Consultancy,
What is zend studio for?
Is not null in php?
Echo is used to Display message on screen. Which is used with echo to not output the trailing newline?
What is the $_ server php_self variable?