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.....

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between instead of trigger and after trigger?

518


How many commands are in sql?

537


What is normalisation and its types?

558


how to write date and time literals? : Sql dba

538


What is scalar data type in pl sql?

569






How many sectors are in a partition?

572


What are triggers in sql?

589


How many times can we commit in a loop?

578


what are the types of subquery? : Sql dba

598


Why coalesce is used in sql?

479


What is java sql driver?

558


What are tables and fields?

599


What are sql injection vulnerabilities?

506


Which are sql * plus commands?

548


What are stuff and replace function?

582