Write a query to find second highest salary of an employee.
Answer Posted / biswojit kar
Getting nth max sal of an Employee.
select sal from (select ename,sal, dense_rank() over(order
by sal desc nulls last) as rank from emp) where rank=n;
Here n = 2 for 2nd highest sal, 3 for 3rd highest sal, 4
for 4th highest sal and so on.One can use rank() in place
of dense_rank(), but the demerit of rank() is as follows:
Let you want to see 3rd highest sal.
Suppose 2 employees have 2nd highest sal, then rank()
assigns both of them rank 2, then it leaves a gap and
assigns the emp with 3rd highest sal to rank 4.
So, when you use the above query with rank(), the you donot
get the 3rd highest sal. Try retrieving 3rd highest sal in
emp table in scott user, using both rank() and dense_rank
(), and mark the diff. Thanks!
| Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
Hi, I wanted to go with TestingDomain-Automation. Regarding this I need to take training on any one tool either WinRunner or LoadRunner. Which is better to get job,having future and takes lesstime with easier***. pls mention one tool name. Basically iam manual test engineer on unix- platform.
What are the attributes of a good framework?
Please explain how to perform load-testing?
Why do you prefer selenium automation tool?
What is a xpath?
Please explain what is the hybrid framework?
Bug report formate in bugzilla
Tell us what automation tools could be used for post-release validation with continuous integration?
On what basis you can map the success of automation testing?
Differentiate between hdam and hidam database?
Explain load testing on websites?
What all things can you automate?
List the five essential types of test steps?
What are the pre-requisites to start automation testing?
Tell me what is automation testing?