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

select * from emp as e1 where 1= (select count(*)from emp
as e2 where e1.sal<e2.sal)

Is This Answer Correct ?    9 Yes 11 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between TRUNCATE and DROP?

633


Delete duplicate rows without using rowid.

1074


What are the system database in sql server 2005?

556


Explain powershell included in sql server 2008?

615


Does any body please help me what question's have asked for SSRS in the interview?

1669






Write a sql query to sort on different column name according to the parameters passed in the function?

536


How many replicas are maintained for each sql azure db?

106


What are the acid properties?

553


What do you understand by coalesce in sql server?

499


Detail about the hardware which is supported by SQL server?

589


Explain atomicity?

579


How to transfer data from a cursor to variables with a "fetch" statement?

583


How many levels of sp nesting are possible?

557


in the physical file layout, where should the transaction log be stored in relation to the data file?

536


What is pessimistic concurrency?

543