Given an employee table, how would you find out the second
highest salary?

Answer Posted / karna

select top 1 a.salary,* from emp a
where a.salary not in(select top (n-1) b.salary from emp b)

here n is the Nth values:if you want secong highest: keep n
as 2 so the query will become

select top 1 a.salary,* from emp a
where a.salary not in(select top 1 b.salary from emp b)

Is This Answer Correct ?    3 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

I have a few records all are same structures data, I want to store data in multiple targets how

2147


What is a database development?

528


Explain about relational database management systems?

576


How to use online Backups?

1739


When installing the datastage7.5x2 edtion iam getting aproblem i.e the cpu count is 2 but the cpu count in installation is one . how can i install in my p.c (system is dual core).

1799






What is DB Development software?

1621


You have a table with three columns: amount1, amount2, and amount3 in a single row only one of these three columns will have a value and the other two will be null. Write a sql query to retrieve the values from these columns?

556


Explain about the hierarchical model of the database?

588


Where is dbms used?

629


State the acid rules?

692


Explain about query and reporting.

1694


What is the physical representation for a many-to-many relationship?

582


What are data modelling techniques?

531


Which data type cannot be used as a parameter in a udf?

582


How would you design a database for an online site, which would average a million hits a day?

589