I am having a problem with a query that joins the following tables. I want
to create a query that would tell me how many Manhours to a particular
project (32) by category and how many hours (from the Tasks table) have
actually been used for this project and category.


Manhours
 mid    | ProjectId |ChargeNum  | Catid         | Hours         | EmployeeId

  1     | 32    |111111         | 19            | 80            | 200020 
  2     | 32            |111111         | 19            | 24            |
200003 


Tasks

TaskID  |ChargeNum  |Catid      |EmployeeId             |Hours  
    1   |111111         |19             |200020                 |8 
    2   |111111         |19             |200020                 |8 
    5   |111111         |19             |200003                 |12 


The query I am using looks like this:

Select M.Catid, sum(M.Hours) as allotedhours, sum(T.Hours) as usedHours
>From Manhours as M, Tasks as T
Where M.ProjectId=32 
AND T.ChargeNum=M.ChargeNum
AND T.EmployeeID=M.EmployeeID
AND T.Catid=M.Catid
Group by M.Catid
Order by M.Catid

The results I am expecting are:

Catid   |allotedhours   |usedHours  
19      |104                    |28 

instead I am getting:

Catid   |allotedhours   |usedHours  
19      |184                    |28 


So I imagine that I am missing something in my join syntax, but I haven't
been able to figure it out.


Luis R. Lebron
Sigmatech, Inc

Reply via email to