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

What is the use of primary key?

0 Answers  


What is Referential Integrity?

3 Answers   IBM,


what are set operators in sql? : Sql dba

0 Answers  


What are system versioned tables?

0 Answers  


How many tables can a sql database have?

0 Answers  






What are the main features of cursor?

0 Answers  


Which are the different types of indexes in sql?

0 Answers  


What is date functions?

0 Answers  


i have a customer table. trans_id trans_date trans_amt debit_credit_indicator 001 01-JAN-13 1099 cr 001 12-JAN-13 500 db 002 24-FEB-13 400 db 002 23-MAR-13 345 cr 001 18-APR-13 800 cr 002 15-MAR-13 600 db 001 12-FEB-13 200 cr i want like this output. trans_id trans_amt debit_credit_indicator i want get highest credit amount and lowest credit amount and highest debit amount and lowest debit amount for each trans_id. pls give me answer. i want urgent

3 Answers  


What is minus?

0 Answers  


What is the maximum number of triggers, you can apply on a single table?

0 Answers  


Can we rollback after truncate?

0 Answers  


Categories