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 / suraj

-- create table #Employees (EID int, EName varchar(20), MID
int)
-- insert #Employees values(101,'Rama',NULL)
-- insert #Employees values(102,'Sita',101)
-- insert #Employees values(103,'Shiva',101)
-- insert #Employees values(104,'Ganesh',103)

--for 103 ID the manager ID is 101(RAMA) and for 104
manager is SIVA
--Write a script which displays Shiva's Manager's name.

select a.EID, a.EName, a.MID, b.EName
from #Employees a
inner join #Employees b on a.mid=b.eid and a.EName='Shiva'

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are the types of indexes? : Sql server database administration

1097


What is equi join with example?

1098


What happens when transaction log is full?

909


What is the difference between a "where" clause and a "having" clause?

1147


in the physical file layout, where should the transaction log be stored in relation to the data file?

973


What does man by sql wildcard characters in sql server?

1040


as a general practice, it is recommended to have dbo be the owner of all database objects however, in your database you find number of tables owned by a user other than dbo, how could you fix this? : Sql server administration

950


Explain what is the difference between a local and a global temporary table?

982


Explain the difference between control flow and data flow?

975


What is pivot and unpivot?

997


What are the essential components of sql server service broker?

1003


Explain syntax for viewing trigger?

904


What are the types of processing and explain each? : sql server analysis services, ssas

1135


How do you send email on SQL Server?

1039


what types of replication are supported in sql server? : Sql server database administration

1018