GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  SQL
Go To First  |  Previous Question  |  Next Question 
 SQL  |  Question 157 of 171    Print  
find manager for employee
ID employee department manager
----------------------------------------------
1 Suresh c++ NULL
2 Suresh c++ NUll
3 Suresh c++ 2
5 Sarathy testing 2
6 Rajaraman c# 1
7 joe Flash 1


I have the employee detail table ,In that i want to find the manager for each employee .
The employee name and manager column are present in same table



  
Total Answers and Comments: 5 Last Update: September 22, 2008     Asked by: rajaramanv 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: mktiwary
 
If you take the normal Oracle Employee (emp) table which consists of columns such as Employee Number (EMPNO) and Manager Number (MGR) then the query to find managers for all the employee is:

select e.ename as Employee, m.ename as Manager from emp e, emp m
where e.MGR = m.EMPNO

Above answer was rated as good by the following members:
singh13
May 26, 2008 13:22:14   #1  
sahil4439 Member Since: May 2008   Contribution: 2    

RE: find manager for employee
select employee_manager
from talbe_name;

 
Is this answer useful? Yes | NoAnswer is useful 0   Answer is not useful 1Overall Rating: -1    
June 06, 2008 05:42:35   #2  
mktiwary Member Since: June 2008   Contribution: 1    

RE: find manager for employee
If you take the normal Oracle Employee (emp) table which consists of columns such as Employee Number (EMPNO) and Manager Number (MGR) then the query to find managers for all the employee is:

select e.ename as Employee m.ename as Manager from emp e emp m
where e.MGR m.EMPNO

 
Is this answer useful? Yes | NoAnswer is useful 1   Answer is not useful 0Overall Rating: +1    
June 27, 2008 12:06:31   #3  
shiv_prakash Member Since: May 2008   Contribution: 2    

There is a '%' sign in one field of a column. What will be the query to find it.,,by Shiv prakash(4c+)
select column from table where column like ' ' ESCAPE '' ;
 
Is this answer useful? Yes | No
July 11, 2008 07:16:35   #4  
krishnaveni_g Member Since: July 2008   Contribution: 10    

RE: find manager for employee
we can find manager for employee in the same table by using self join.

Ex:emp_id emp_name manager_id
1 Smith
2 Rahul 1
3 Sachin 2

Select e.emp_id e.emp_name m.last_name from
employees e employees m
where e.manager_id m.employee_id;

 
Is this answer useful? Yes | No
September 22, 2008 03:10:28   #5  
shiiva Member Since: September 2008   Contribution: 2    

RE: find manager for employee
SELECT e.ename as Manager m.ename as Employee FROM emp e emp m WHERE e.MGR m.EMPNO
 
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