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



i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

Answer / adil

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 ?    1 Yes 0 No

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

i have a table emp and columns ename,empno,mgr_id,i need ename,manager name as result i.e employee r..

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

Post New Answer

More SQL PLSQL Interview Questions

How would you pass hints to the sql processor?

0 Answers  


If i insert record in table A and these record should update in table B by using Trigger.How to achieve this.

4 Answers   Saama Tech, TCS,


Can sql function call stored procedure?

0 Answers  


need to split a string into seperate values. eg. col1 col2 ---------- 100 - 'a,b,c' 200 - 'a,x,b,d,e' 300 - 'c' result: value count ------------- a - 2 b - 1 c - 2 etc.

1 Answers  


Explain clause in sql?

0 Answers  






Differentiate between % rowtype and type record.

0 Answers  


What is an Integrity Constraint?

4 Answers  


what is the difference between pragma exception_init and raise_application_error

1 Answers   Aetins, State Street,


How to start oracle sql developer?

0 Answers  


What is meant by <> in sql?

0 Answers  


What will be the output for the below Query Select 'High' from dual where null = null;

12 Answers   Infosys, Satyam,


What is the use of function "module procedure" in pl/sql?

0 Answers  


Categories