Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

How to read xml file in oracle pl sql?

916


What is dense_rank in sql?

993


what are the differences between procedure-oriented languages and object-oriented languages? : Sql dba

1056


How many rows can sqlite handle?

1121


What is difference between table and view?

1066


Can we update views in sql?

942


How to avoid duplicate records in a query?

1012


How to change sql*plus system settings?

1059


How to write a query to show the details of a student from students table whose

1003


how can we take a backup of a mysql table and how can we restore it. ? : Sql dba

977


Difference between truncate, delete and drop commands?

1088


Why use truncate instead of delete?

1020


what is error ora-03113: end-of-file on communication channel?

1169


What are the different types of triggers?

1139


What is recursive stored procedure?

1103