GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 130 of 171    Print  
List all the employees who have atleast one person reporting to them
List the employee details if and only if more than 10 employees are presently in department 10

  
Total Answers and Comments: 4 Last Update: June 06, 2009     Asked by: rambabu 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
May 23, 2007 02:55:34   #1  
Sangeetha Sivakumar        

RE: List all the employees who have atleast one person...

select empid empname
from employees a
where EXISTS (select manager_id from employees where empid a.empid)


 
Is this answer useful? Yes | No
September 23, 2007 08:11:23   #2  
Enrique        

RE: List all the employees who have atleast one person...
/*
* b) List the employee details if and only if more than 10 employees are presently in department 10
*/
/*This Query Is More Generic instead of Department 10 it searches for any Department*/
SELECT *
FROM Eml
WHERE Dpt IN (SELECT CASE
WHEN COUNT(Dpt) > 10 THEN Dpt
ELSE NULL
END
FROM Eml
GROUP BY Dpt);

 
Is this answer useful? Yes | No
July 07, 2008 13:59:09   #3  
chaitanya61 Member Since: July 2008   Contribution: 3    

RE: List all the employees who have atleast one person reporting to themList the employee details if and only if more than 10 employees are presently in department 10
This query lists all the employees who have atleast one person reporting

select ename cnt
from (select ename count(*) over (partition by mgr) cnt from emp order by cnt)
where cnt >1;

 
Is this answer useful? Yes | No
June 05, 2009 08:35:12   #4  
sumanta.bala Member Since: June 2009   Contribution: 2    

RE: List all the employees who have atleast one person reporting to themList the employee details if and only if more than 10 employees are presently in department 10
Use the following query. we are just using the same table twice to find the employess who are having some employee under them or they are mgr

SELECT emp_tab.ename

emp_tab.job

emp_tab.deptno

FROM scott.emp emp_tab

scott.emp mgr_tab

WHERE mgr_tab.mgr emp_tab.empno

GROUP BY emp_tab.ename

emp_tab.job

emp_tab.deptno

HAVING COUNT (mgr_tab.empno) > 0


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape