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 sql server locking?
How to count rows with the count(*) function in ms sql server?
Write a SQL query to make a column as unique?
What are the differences between web role and worker role?
Explain a differential backup?
What is filestream?
If you're given a raw data table, how would perform etl (extract, transform, load) with sql to obtain the data in a desired format?
What is recursion? Is it possible for a stored procedure to call itself or recursive stored procedure? How many levels of sp nesting are possible?
How to defragment indexes with alter index ... Reorganize?
What is wrong with sql server client libarary dll, ntwdblib.dll?
What is join query?
What is normalization according to you and explain its different levels?
List few advantages of stored procedure.
Explain security with sql azure?
We are updating a field in sql and alter the row also.after giving the commit command the system is crashed.what will happen to the commands given,whether it will update and alter the table or not?