i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee respective manager.. example
empno ename mgr_id
1 john 3
2 paul 3
3 smith 1
4 kevin 1
5 stewart 2
result has to look like this
ename manager
john smith
paul smith
smith john
kevin john
stewart paul
can u plz help me out in this.....
Answers were Sorted based on User's Feedback
Answer / praveen h
I think this one will work
Select a.ename as Employee ,b.ename as Manager from
EMP ,EMP B
where
A.MGR_ID=B.empno
Is This Answer Correct ? | 9 Yes | 2 No |
Answer / rajesh venati
select e.ename as employee_name,m.ename as manager_name from
emp e, emp m where e.mgr_id=m.empno;
Is This Answer Correct ? | 8 Yes | 2 No |
Answer / cbigmudre
select a.ename, b.enanme as manager
from emp as a, emp as b
where a.empno = b.mgr_id
Is This Answer Correct ? | 2 Yes | 1 No |
Answer / karthik
select e1.empno,e1.ename EmpName,e2.ename MgrName from emp e1,emp e2
where e1.mgr_id=e2.ename(+);
select e1.empno,e1.ename EmpName,e2.ename MgrName
from emp e1 left outer join emp e2
where e1.mgr_id=e2.ename;
Is This Answer Correct ? | 0 Yes | 0 No |
Answer / sudhan
select e1.ename EmpName,e2.ename MgrName from emp e1,emp e2
where e1.mgr_id=e2.ename;
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / john bershan
self join will accomplish this task.try below query
select a.ename,b.ename as manager from emp a,emp b
where a.empno = b.mgrid;
Is This Answer Correct ? | 0 Yes | 1 No |
Answer / monika
select empno,ename
from emp
start with mgr_id is null
connect by prior empno=mgr_id;
Is This Answer Correct ? | 0 Yes | 2 No |
what is the boundary line in varrays?
what are the differences among these table level lock modes - IN SHARE MODE, IN SHARE UPDATE MODE, IN EXCLUSIVE MODE ?
define different types of trigger. : Sql dba
Is natural join same as inner join?
What is having clause in sql?
What is string join?
How do I run a sql query?
Write a procedure to return the month and the number of developers joined in each month (cursor )
What are the different types of joins in sql?
1) Synonyms 2) Co-related Subquery 3) Different Jobs in Plsql 4) Explain Plan 5) Wrap 6) Query Optimization Technique 7) Bulk Collect 8) Types of index 9) IF primary key is created then the index created ? 10) Foreign Key 11) Exception Handling 12) Difference Between Delete and Trunc 13) Procedure Overloading 14) Grant Revoke 15) Procedure Argument types. 16) Functions. 17) Joins
What is duration in sql profiler trace?
What is scope and visibility in PL/SQL?