Write a query to find second highest salary of an employee.

Answer Posted / humayun quaiser

slect max(sal) from emp
where sal not in (select max(sal) from emp);

or

select max(sal) from emp
where sal<(select max(sal) from emp);

or

select distinct sal from emp e
where 1=(select count(distinct sal) from emp
where sal>e.sal);

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I order by ascending in sql?

535


How many joins in sql?

551


what is acid property in database? : Sql dba

559


What is int identity in sql?

572


How do you concatenate in sql?

548






Does a primary key have to be a number?

518


How do I run a pl sql procedure in sql developer?

508


What is the difference between numeric and autonumber?

498


What is the difference among union, minus and intersect?

544


Define overloaded procedure?

620


What is $$ in sql?

549


What is sqlite used for?

528


What is percent sign in sql?

713


Explain the components of sql?

587


What is sql exception?

515