How to find second highest salary

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How is it possible to know the number of rows returned in result set?

523


What websites use php?

517


What is the scope of a variable defined outside a function?

537


How does the identity operator === compare two values?

672


What is the purpose of the php empty function?

488






Tell me how to strip whitespace (or other characters) from the beginning and end of a string?

530


What is php explain how php works?

521


what is benefit of magento?

2031


Does php support multithreading?

551


What is super keyword in php?

515


What is an operator in php?

568


List some sorting functions in php?

549


Is php fully object oriented?

486


How to get the directory name out of a file path name?

538


Why json is used in php?

539