Hi all,
Hope some one can help me with this. I have a table of contacts, each record has (for simplicity) ContactID, Name, ManagerID.
I am able to get staff that work for a manager, and have this working as a drilldown reports, but need to arrange it from the top manager level, where a top level manager manages middler manager, who in turn manage staff (hope this makes sense!!)
I'm struggling to add a top level to the query i have:
How do i combine the two to get a "tree" of top level manager, middle managers and all staff?
Thanks - this one has me a little baffled???
Hope some one can help me with this. I have a table of contacts, each record has (for simplicity) ContactID, Name, ManagerID.
I am able to get staff that work for a manager, and have this working as a drilldown reports, but need to arrange it from the top manager level, where a top level manager manages middler manager, who in turn manage staff (hope this makes sense!!)
I'm struggling to add a top level to the query i have:
Code:
/********This is to get the top level manager....****/
SELECT CONTACTS_1.ID AS AdviserCode, CONTACTS_1.DisplayName AS AdviserName, CONTACTS_1.ManagerID AS ManagerRef,
CONTACTS.DisplayName AS ManagerName
FROM CONTACTS RIGHT OUTER JOIN
CONTACTS AS CONTACTS_1 ON CONTACTS.ID = CONTACTS_1.ManagerID
WHERE (CONTACTS_1.ManagerID = 5455)
ORDER BY AdviserName
/*********This is the query i have to list all staff under a middle manager**************/
/*****Parameter @Manager is populated when this report is run ************/
SELECT ID AS AdviserCode, Firstname, Surname, DisplayName, Org_Ref AS OrganisationRef, ManagerID AS ManagerRef
FROM CONTACTS
WHERE (ManagerID = @Manager)
ORDER BY Surname
How do i combine the two to get a "tree" of top level manager, middle managers and all staff?
Thanks - this one has me a little baffled???