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 / ashish

hey u can try This It defenately work...It for The nth
position mean for the N th node try it out.......



SELECT *
FROM emp A
WHERE (n-1) = (
SELECT COUNT(DISTINCT(B.salary))
FROM emp B
WHERE B.salary > A.salary)

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain use of expression builder.

571


Explain the cursor lock types?

557


What is outer join in sql server joins?

602


How many types of triggers in sql server?

525


What are the difference between clustered and a non-clustered index?

595






What is transact-sql ddl trigger?

642


What are the different types of lock modes in sql server 2000?

495


Explain linked server in sql?

700


Do you know what are the reporting services components?

539


What are the steps you should follow to start sql server in single-user mode?

491


Can you explain important index characteristics?

531


How many primary keys are possible in a table?

522


What is the library index called?

596


How can you know if the row fetched from cursor is still valid in underlying table?

524


What is the default value of an integer data type in sql server 2005?

590