how to find the second salary?

Answer Posted / vishnu

Here we can find out 2nd highest salary in many ways,
according to the situation we can select anyone…
1st Type:
select min(esal) from emp where esal in (select top 2 esal
from emp order by esal desc)

2nd Type:
select max(esal) from emp where esal not in(select max(esal)
from emp)

3rd Type:
select max(esal) from emp where esal <(select max(esal) from
emp )

4th Type:
select Max(esal) from EMP a where 2=(select
COUNT(distinct(esal)) from EMP b where a.eSAL<=b.eSAL);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

A user is a member of the public role and the sales role. The public role has select permission on all the tables. The sales role does not have select permission on some of the tables will the user be able to select from all tables?

524


how to create “alternate row colour”?

109


How to update multiple rows with one update statement in ms sql server?

638


Explain what are commit and rollback in sql?

531


What is row_number function?

595






What is use of attribute hierarchy ordered ? : sql server analysis services, ssas

560


Define inner join? Explain with an example?

516


What is store procedure? How do they work? When do you use?

513


How to configure and test odbc dsn settings?

575


How do I debug a stored procedure in sql server?

539


List out the differences between the clustered index and non-clustered index in sql server?

506


What is the difference between resultset and resultsetmetadata?

520


What is ems sql management studio? : sql server management studio

587


What is the difference between an index and a unique index?

548


Tell me about normalization in DBMS.

583