I Have Employee table having column name as ID,SALARY
how to get second max salary from employee table with id
ex
ID SALARY
1 20000
7 37000
2 5000

Answer Posted / tusar

select distinct (a.sal),empno from emp a
where &N = (select count (distinct(b.sal))
from emp b where a.sal <= b.sal);

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is a mixed extent? : Sql server administration

597


What is primary key, unique key, and foreign key?

534


Why transaction is important?

557


What is difference between after and before?

498


Tell me what are the essential components of sql server service broker?

502






How to download and install microsoft .net framework version 2.0?

542


How to delete a login name in ms sql server?

524


Write the queries for commands like Create Table, Delete table, Drop Table etc.

602


List the ways in which dynamic sql can be executed?

634


How much is a sql server license?

501


What are views in ms sql server?

592


What is save transaction and save point?

619


What is a recursive stored procedure in sql server?

561


What is candidate key with example?

506


Some queries related to SQL

582