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
Can an extended stored procedure be called from inside a user-defined function?
Which four data types cannot be used as a return type from a user-defined function?
You are testing the performance of a query the first time you run the query, the performance is slow. the second time you run the query, the performance is fast. why is this?
How to use online Backups?
Explain about query and reporting.
How can you fix a poorly performing query?
What is data modeling with example?
What are the key features of dbms?
Explain about normal forms?
Explain what a database is?
explain detail about ftp in datastage?
Explain about network model?
What is dbms and its application?
What is an application role and explain a scenario when you would use one?
What are the constraints on severity level in raiseerror?