table:employee
EID ENAME MID(manager ids)
101 rama null
102 sita 101
103 siva 101
104 ganesh 103
. . .
. . .
for 103 ID the manager ID is 101(RAMA) and for 104 manager
is SIVA
if i give employee id (EID) you have to tell the manager for
that EID write query?
eample:if i give 102 .The query output should be manager for
102 ID that it should print RAMA as output
Answer Posted / saravanan p
Declare @eid int
Set @eid=2
select 'The manager for employee id '+convert(varchar
(50),e2.eid)+' is '+e1.ename from emp e1,emp e2
where e1.eid=e2.mid and e2.eid=@eid
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is the purpose of object explorer and its features? : sql server management studio
Do you know what is a with(nolock)?
What is mean by clustered index and non clustered index, give syntax of creation? : sql server database administration
What are the new features introduced in SQL Server 2000? What changed between the previous version of SQL Server and the current version?
What is Cross Join and in which scenario do we use Cross Join?
Is it possible in sql table to have more than one foreign key?
Explain triggers?
What are the differences between union, intersect, and minus operators?
explain different types of cursors? : Sql server database administration
What is the most common type of join?
how many no of arguments can be passed in procedures and functions
Difference between report and query parameter.
How dts is used to extract, transform and consolidate data?
What is save transaction and save point?
What is ems sql management studio? : sql server management studio