GeekInterview.com
Answered Questions

Dispaly employee records who gets more salary than the average salary in their department?

Asked By: kowmudiswarna | Asked On: Sep 14th, 2007

Answered by: farhan on: Apr 20th, 2012

Code
  1. SELECT * FROM emp  WHERE sal >(SELECT avg(sal) FROM emp)

Answered by: uma on: Mar 5th, 2012

select * from emp a
where salary >(select avg(salary) from emp b where a.dept_no = b.dept_no);

Find out nth highest salary from emp table

Asked By: Interview Candidate | Asked On: Aug 29th, 2004

Select distinct (a.Sal) from emp a where &n = (select count (distinct (b.Sal)) from emp b where a.Sal < = b.Sal);for eg:-enter value for n: 2sal---------3700

Answered by: bhavikgore on: Oct 27th, 2012

This will work for only highest salary n=1 but not work for 2nd and rest nth salary...
Did you have tried this?

Answered by: rohitosu on: Jul 30th, 2012

Code
  1.  SELECT * FROM  (SELECT employee_id, salary, dense_rank() OVER ( ORDER BY salary DESC)  r
  2.   FROM employees) a
  3.   WHERE a.r =3 ;

Interview Question

 Ask Interview Question?

 

Career Counselling

 Have Career Question?

 Ask Chandra

 Ask Only Career questions.

Follow us: