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 different types of backups avaialabe in sql server? : Sql server database administration

584


How do you check sql server is up and running?

508


Explain trigger and its types?

606


what changed between the previous version of sql server and the current version? : Sql server database administration

513


While using a cursor, how can you differentiate between a deleted row and a row that has been inserted with null data values?

547






Why is replication required on the sql server?

569


What do you mean by sql server agent?

531


What command must you use to include the not null constraint after a table has already been created?

538


Describe the left outer join & right outer join. : sql server database administration

578


What are the drawbacks of reporting in ssrs?

106


Describe in brief sql server monitoring ways.

583


When do you think a developer should use sql server-based cursors?

517


Mention the command used to rename the database.

532


What happens if the update subquery returns no rows in ms sql server?

585


What is a subquery in a select query statement in ms sql server?

579