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 / mohana krishna
select ename from employee
where eid = (select case mid when null then aid
else mid end mid
where eid=@aid
)
select m.name from employee e
join employee m on (m.aid=e.mid)
| Is This Answer Correct ? | 0 Yes | 3 No |
Post New Answer View All Answers
Can a table be moved to different filegroup?
What is the usage of sign function?
What is the difference between the export /import functions in sql studio and standalone sql manager? : sql server management studio
Can truncate be rolled back?
Insert syudents details in table.Current system date &time insert into joining time.How do insert?( in sysdate only return current system date how do add time?)
How to call stored procedure using http soap?
Find columns used in stored procedure?
When columns are added to existing tables, what do they initially contain?
Write an SQL query to obtain the 2nd highest salary.
What is open database communication (odbc)?
What are sql server functions?
Explain what role entity and relationship play in an ER diagram.
How to delete multiple rows with one delete statement in ms sql server?
Who is the owner of a schema in ms sql server?
How do I manually uninstall an instance of sql server 2016?