Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 / soorai ganesh

create table emp (eid int, ename varchar(50),mid int)

insert into emp values(1,'Ganesh',null)
insert into emp values(2,'Ramesh',1)
insert into emp values(3,'Suresh',1)
insert into emp values(4,'Selvam',2)
insert into emp values(5,'Vignesh',3)

select * from emp

Declare @eid int
Set @eid = 4 -- Your Input ID here..

Select 'Manager For '+CONVERT(VARCHAR,emp2.eid)+' --> '+ emp1.ename
From emp emp1
Inner join emp emp2 on emp1.eid = emp2.mid and emp2.eid = @eid

Is This Answer Correct ?    4 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the difference between union and union all?

1070


Where sql server user names and passwords are stored in sql server? : sql server database administration

1106


What happens if null values are involved in comparison operations?

1043


What are Spatial data types in SQL Server 2008

1073


Explain iaas, paas and saas?

92


Name few endpoints exposed by ssrs 2012?

366


Types of Authentications in Sql Server? How user gets authenticated through windows authentication?

1100


what is raid and what are different types of raid configurations? : Sql server database administration

1105


What do you understand by coalesce in sql server?

1129


What do you understand by the data quality services in sql server?

984


What is attribute relationships, why we need it? : sql server analysis services, ssas

1032


What is the purpose of optimization?

1061


How to modify an existing user defined function?

1172


What are the types of dml?

1032


What is acid mean in sql server?

1203