GeekInterview.com
Series: Subject: Topic:
Question: 8 of 214

how to find the employee who get seventh largest salary in the company?

Asked by: mithrz | Member Since Aug-2012 | Asked on: Aug 19th, 2012

View all questions by mithrz

Showing Answers 1 - 3 of 3 Answers
Bala

Answered On : Aug 25th, 2012

Code
  1.  
  2. SELECT salary FROM
  3. (SELECT salary, dense_rank() over (ORDER BY salary)
  4. FROM emp)
  5. WHERE dense_rank = 7;
  6.  

  
Login to rate this answer.
gowtham

Answered On : Oct 1st, 2012

select salary data only

  
Login to rate this answer.
Amninder

Answered On : Apr 15th, 2013

Select emp_id,emp_name,salary from employee a,
(Select salary,dense_Rank() over (order by salary DESC) rank_sal from employee)b
where a.salary=b.salary
and rank_sal=7;

The Inline Query will order salary by descending order and will correspondingly rank them, and by joining the salary present at 7th number with the main table, we can find the required data.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.