Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Tell me what is tsl? What 4gl is it similar too?

1022


What are the steps to perform Load and Stress testing on a Website? What resources do I need to do this? Please advise. Thanks in advance.

1988


how to re-install QTP 11.0 trial version

2668


When will you not automate testing?

1028


What are the different types of an automation tool that you are aware of?

1042


What is junit annotation?

1027


Is ui level testing possible?

990


What should you do after finding a bug?

1116


List out some of the automation tools which could be integrated with selenium to achieve continuous testing.

917


What are the advantages of automation testing?

986


Name some of the commonly used automation testing tools that are used for functional automation.

967


What are the references for TSL functions.? Could anybody suggest me recommended book for Test Script Language.

2148


Do you know what is the purpose of deselectall() method?

1023


How is Jmeter tool very useful in projects when it does not have features like online monitoring,WAN emulation,caching like other performance tools.

2428


What you know about table-driven testing?

1078