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

What is the result, when NULL is compared with NULL?

22 Answers   TCS,


how to create a primary key with out creating an index?

9 Answers   TCS,


what is innodb? : Sql dba

0 Answers  


what is mean by forward declaration and where we'll use it.

4 Answers   TCS,


What is the difference between pl and sql?

0 Answers  






What are %type and %rowtype for?

0 Answers  


how to get the third quarter of employee details from emp?

2 Answers   CompuTech,


What can you do with pl sql?

0 Answers  


how to convert character strings to numeric values? : Sql dba

0 Answers  


take one table is t1 and in that column name is f1 f1 column values are 200 5000 3000 7000 300 600 100 400 800 400 i want display the values asc and desc in a single output. sample output is f1.a 100 200 300 400 500 600 etc...... and f1.d is 5000 4000 3000 2000 1000 etc...

9 Answers   Zensar,


When we can declare a column as Unique and Not Null both at the same time. What is the use pf Primary Key then?

2 Answers   Accenture, Unisoft Infotech,


What is dynamic sql in pl sql?

0 Answers  


Categories