I have the following 3 tables set up and need to know how to calculate the total price which is based on (BaseCost + Hours * Rate). Table 2 can have many different departments for the same part. Table 3 has different rates for each department. For example, I have PartID (7) which hase a BaseCost ($365) for Table 1. Table 2 has PartID (7), Hours (3) and Department (Mechanical) and also has same PartID (7), Hours (4) and Department (Electrical). Table 3 has Department (Electrical) and Rate ($40) and has Department (Mechanical) and Rate ($45). The total cost is the base cost plus hours * rate for all departments. For this example is should be 365 + (3 *45) + (4*40) = 660.
Table 1
PartID
BaseCost
Table 2
PartID
Hours
Department
Table 3
Department
Rate
Can you give me an example of SQL code? I have tried to set up the query, but I get 2 records returned which is the base cost + department cost for one department and the 2nd record is the different department cost = base cost. Also, how should the relationships be set up? I have 1 to many from Table 1 to Table 2 and a 1 to many from Table 3 to Table 2.
Thanks,
Tom
Table 1
PartID
BaseCost
Table 2
PartID
Hours
Department
Table 3
Department
Rate
Can you give me an example of SQL code? I have tried to set up the query, but I get 2 records returned which is the base cost + department cost for one department and the 2nd record is the different department cost = base cost. Also, how should the relationships be set up? I have 1 to many from Table 1 to Table 2 and a 1 to many from Table 3 to Table 2.
Thanks,
Tom