Hi all,
i have a table as follows
empid empname mgrid deptid
1 a 3 4
2 b 1 5
3 c 2 3
4 d 3 6
5 e 4 7

i want the output as
empname mgrname
a c
b a
c b
d c
e d

Answers were Sorted based on User's Feedback



Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b ..

Answer / gunturajesh

select a.empname empname,b.empname mgrname from emp a,emp b
where a.mgrid=b.empid

Is This Answer Correct ?    20 Yes 2 No

Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b ..

Answer / suresh babu

select t1.empname,t2.empname from emp t1,emp t2 where
t1.mgrid = t2.empid;

This query is self join,Which is display your requirement.

Is This Answer Correct ?    4 Yes 0 No

Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b ..

Answer / alok narayan

1.
select empname,(select empname from e1 b
where b.empid =a.mgrid) from e1 a;

2.
select a.empname empname,b.empname mgrname from e1 a,e1 b
where a.mgrid=b.empid order by a.empname ;

Is This Answer Correct ?    0 Yes 0 No

Hi all, i have a table as follows empid empname mgrid deptid 1 a 3 4 2 b ..

Answer / nanne saheb c

select e.empname,m.ename mgrname from emp e,emp m
where e.mgrid=m.empid;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

Explain what is a database?

0 Answers  


How do I copy a table in sql?

0 Answers  


Can we join tables without foreign key?

0 Answers  


Explain the difference between sql and mysql.

0 Answers  


How is sql used in oracle?

0 Answers  






How would you hide a table in sql. ie the table can be only visible to its maker?

3 Answers  


Explain the uses of control file.

0 Answers  


there is A table and B table in A table there 5 rows and in b table there are 2 rows i am firing query select * from a,b what will be the output?

7 Answers   Cognizant,


Difference between aggregate function and analytical function?

3 Answers   Metric Stream,


Question: Below is the table city gender name delhi male a delhi female b mumbai male c mumbai female d delhi male e I want the o/p as follows: male female delhi 2 1 mumbai 1 1 Please help me in writing the query that can yield the o/p mentioned above?

2 Answers  


how to create a database in oracle?

3 Answers  


What is difference between joins and union?

0 Answers  


Categories