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

Kindly let me know how to setup JMeter for functionality testing of a Web application.. The apache help doc is good but i m little confused with it... :(

2210


Tell me how would you test your own element locator?

1008


When do you prefer manual testing over automation testing?

978


How many test cases have you automated per day?

1031


Can any one give me the script for drag and drop or setselection functions ?like in a not pad i want to select 5 lines

2001


What is the difference between continue and next sentence?

1122


What are the different types of testing framework techniques?

989


what is the difference between keyword driven frame work and data driven frame work.

2333


hi i would like to know is there any training institue for Calabash,robotium and ui automator in hyderabad...urgent

3027


Tell me what is the purpose of getoptions() method?

985


Give some examples for defect management tools?

1068


Do you think that testing can be done only at the ui level?

1102


Does every software project need testers?

998


VSTET (Visual Studio Team Edition for Testers) which is in TFS (Team Foundation Server) - In what way is VSTET better than QTP?

3697


Hi, I want to learn DataBase Testing. So please some document or path so that i can get some material on DataBase Testing concepts (preferably SQL Server 2000). Thanks in advance, Guru

3797