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

select top 1 id,salary from(select top 2 id,salary from
employee group by id,salary order by salary desc)a order by
salary asc

Is This Answer Correct ?    5 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different Topologies in which Replication can be configured?

859


What is update_statistics command?

765


How to download and install sql server 2005 books online?

763


What are the differences between having and where clause.

710


what are the different ways of moving data/databases between servers and databases in sql server? : Sql server database administration

708






What are wait types?

737


How do I edit a procedure in sql server?

717


When you should use a low fill factor?

720


Why do we use sql limitations? Which constraints can we use while making a database in sql?

744


What is a dbms wizard?

771


Give an example of why you would want to denormalize a database

712


Differentiate between delete and truncate.

749


Create and insert into temp table in sql server?

782


Explain powershell included in sql server 2008?

769


What do you mean by acid?

758