I don't know how to begin on a query (SELECT statement) to find all the
tasks assigned to an arbitrary manager (say, staffID='JSmith ') and her
organization, that is, assigned to all her underlings, and their underlings,
and .... For that matter, I don't even know how to find everyone in her
organization (at all levels).
- All individuals have only one manager
- Tasks are assigned to individuals
- A manager at any level may have direct reports and sub-managers
The table structure:
tblStaff
-------------
staffID
reportsToID (staffID of direct manager)
tblTasks
--------------
taskID
assignedToID (staffID of individual responsible for task)
Any help would be greatly appreciated.
Bruce 7 11024
Bruce Hensley wrote: I don't know how to begin on a query (SELECT statement) to find all
the tasks assigned to an arbitrary manager (say, staffID='JSmith ') and
her organization, that is, assigned to all her underlings, and their
underlings, and .... For that matter, I don't even know how to find everyone in
her organization (at all levels).
- All individuals have only one manager - Tasks are assigned to individuals - A manager at any level may have direct reports and sub-managers
The table structure:
tblStaff ------------- staffID reportsToID (staffID of direct manager)
tblTasks -------------- taskID assignedToID (staffID of individual responsible for task)
Any help would be greatly appreciated.
Bruce
You can find information about hierarchical queries at http://download-west.oracle.com/docs...4a.htm#2053937
URL may wrap.
Regards
/Rauf
On 15 Feb 2005 10:17:15 -0800, "Rauf Sarwar" <rs******@hotma il.com>
wrote: Bruce Hensley wrote: I don't know how to begin on a query (SELECT statement) to find all the tasks assigned to an arbitrary manager (say, staffID='JSmith ') and her organization, that is, assigned to all her underlings, and their underlings, and .... For that matter, I don't even know how to find everyone in her organization (at all levels).
- All individuals have only one manager - Tasks are assigned to individuals - A manager at any level may have direct reports and sub-managers
The table structure:
tblStaff ------------- staffID reportsToID (staffID of direct manager)
tblTasks -------------- taskID assignedToID (staffID of individual responsible for task)
Any help would be greatly appreciated.
Bruce
I haven't used them yet but you may find the Shaped Query for ADO
helpful.
Just do a search in Google.
Good luck.
Greg Teets
Cincinnati Ohio USA
Rauf,
Thanks! Excellent!!
This is perfect for my Oracle data.
Now I need to do the same in Access 97 tables. I can't find anything
similar
to CONNECT BY for Access 97.
Bruce
Rauf Sarwar wrote: Bruce Hensley wrote: I don't know how to begin on a query (SELECT statement) to find all the tasks assigned to an arbitrary manager (say, staffID='JSmith ') and her organization, that is, assigned to all her underlings, and their underlings, and .... For that matter, I don't even know how to find everyone
in her organization (at all levels).
- All individuals have only one manager - Tasks are assigned to individuals - A manager at any level may have direct reports and sub-managers
The table structure:
tblStaff ------------- staffID reportsToID (staffID of direct manager)
tblTasks -------------- taskID assignedToID (staffID of individual responsible for task)
Any help would be greatly appreciated.
Bruce You can find information about hierarchical queries at http://download-west.oracle.com/docs...4a.htm#2053937 URL may wrap.
Regards /Rauf
Greg,
Thanks for the tip. However, I can't seem to find anything in the
Access 97 documentation on the SHAPE command. I think it may have been
introduced with Access 2000.
Bruce
David,
Thanks. That was an interesting read.
Unfortunately, I've inherited the tables and can't change them, just
read them.
However, I can estimate the maximum number of levels in the tree. With
this in mind, I tried a brute force approach. This seems to get all
the staff below a manager (as long as they're no more than 6 levels
deep). Not elegant, but it seems to be effective.
SELECT tblStaff.StaffI D, [tblStaff]![StaffID] & " " &
[tblStaff]![ReportsToID] & " " & [B2]![ReportsToID] & " " &
[B3]![ReportsToID] & " " & [B4]![ReportsToID] & " " &
[B5]![ReportsToID] AS ChainOCmd
FROM ((((tblStaff LEFT JOIN tblStaff AS B1 ON tblStaff.Report sToID =
B1.StaffID) LEFT JOIN tblStaff AS B2 ON B1.ReportsToID = B2.StaffID)
LEFT JOIN tblStaff AS B3 ON B2.ReportsToID = B3.StaffID) LEFT JOIN
tblStaff AS B4 ON B3.ReportsToID = B4.StaffID) LEFT JOIN tblStaff AS B5
ON B4.ReportsToID = B5.StaffID
WHERE ((([tblStaff]![StaffID] & " " & [tblStaff]![ReportsToID] & " " &
[B2]![ReportsToID] & " " & [B3]![ReportsToID] & " " &
[B4]![ReportsToID] & " " & [B5]![ReportsToID]) Like "*" & [Boss: ] &
"*"));
Thanks,
Bruce
If you _know_ the number of levels of the hierarchy in advance, then
this is probably the way to go. Otherwise you're probably going to
need to resort to a recursive VBA code solution of some kind. It would
be an intriguing exercise to combine the two, i.e., write code to
determine the actual depth of the hierarchy based on your actual data
and then actually generate the SQL from code...
Bruce This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mike N. |
last post by:
Hello to all:
First let me apologize for the length of this question, I've made an attempt
to include as much information as is needed to help with the question.
I am having problems putting together a query to pull out an alternative
hierarchical view of my data. The database is implemented under SQL Sever
2000 and I am writing the front end using VB.Net and ADO.net. The following
is the portion of my database structure that I am...
|
by: joey |
last post by:
I have a SQL query where I get the count of something, but what I really
want is a yes/no (boolean) answer. Here is my query:
SELECT COUNT(*) AS COUNT FROM hd_entries,hierarchy WHERE
IFNULL (BETWEEN_TIMES (b_yr, b_day, b_msec, e_yr, e_day, e_msec,
2001, 31, 0, 2001, 31, 63720000) >0, 1) AND
hd_entries.data_key=hierarchy.data_key AND
hierarchy.project='CLUSTERII' AND
hierarchy.mission='CLUSTER-4' AND
hierarchy.experiment='PEACE';
|
by: Karam Chand |
last post by:
Hello
I have been working with Access and MySQL for pretty
long time. Very simple and able to perform their jobs.
I dont need to start a flame anymore :)
I have to work with PGSQL for my companies current
project.
I have been able to setup postgresql in my rh box and
|
by: Sakcee |
last post by:
Hi
I have a script e.g.
import package.module
ID = "55"
package.module.checkID()
|
by: salesmr |
last post by:
I have a query that works fine in Oracle, but I can't seem to get it to work in PHP. The code is:
$query = "SELECT lpad(' ', (level - 1) * 4) || emp_name, level ";
$query .= "from emp_table";
$query .= "CONNECT BY manager_id = prior emp_id ";
$query .= "START WITH emp_id = '1234567' ";
$result = odbc_do($connection, $query);
while(odbc_fetch_into($result,&$fields))
{
| |
by: BSB |
last post by:
IIf(IsNull()=True And IsNull(!)=True,"UNKNOWN",IIf((!)="CHECK" And (Left(,2)="58" Or Left(,2)="59"),"Residential",IIf((!)="CHECK" And Left(,2)="56","Commercial",IIf(IsNull()=True Or ()="",!,IIf(IsNull(!)=True And IsNull(!)=True,"UNKNOWN",IIf(IsNull(!)=True,(!),IIf(IsNull(!)=False,(!),"")))))))
Can anyone help me out in converting this
Thanks in Advance
|
by: nintesa |
last post by:
I'm using Oscommerce, Joomla, Mambo ecc... everyone of these have a good
multilevel admin panel.
Now I'm developing a new indipendent little application ad I'm wondering
if there is a small multilevel admin panel that I can easyly adapt for
my application.
Can anyone help me?
(I'm sorry about my poor English...)
|
by: Tem |
last post by:
I have a table that looks like this. Each row is a reply or a topic when
IsAReplyTo = 0
I need to write a query that pulls all rows of a hierarchy of a given ID
Table Forum
ID IsAReplyTo
4 0
9 4
27 4
63 27
|
by: IAuditor |
last post by:
Access 2003, XP - I have a multi-table query that is losing data. 1 table is a lookup (Hierarchy), and the other 3 are virtual duplicates (all with a one-to-many relationship with the lookup) except for some field names. The Hierarchy field is identically named in all 3 tables. The query starts with the Hierarchy number, then descriptions, etc. Next are 2 long-integer fields that are used to calculate a Difference and %ofDifference fields. Up...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |