I have an issue i cant seem to resolve where I am trying to sum some datacells in a column based on a foreign key.
I have 3 tables. One table is for my assets, one table is for different projects my assets can be assigned to, and a third table linking each project and asset and lists material transferred by that asset on that project, also a many to many relationship.
tblAsset.ID is PK in tblAsset
tblAsset.Serial contains the serial number of the assets
tblProject.ID is PK in tblProject
tblTransfer.Project is FK linked to tblProject.ID
tblTransfer.Asset is FK linked to tblAsset.ID
tblTransfer.Transfers lists how much material istransferred by my asset on that project.
What i want to do is create a query that show the Serial of each asset, and sums the transported material of all the projects it has been to.
===========================
Example:
Asset1 (ID=1) has been to project P1(ID=1) and transferred 10 tons, P2 (ID=2)transferring 14 tons, and P3(ID=3) transferring 5 tons.
Asset2(ID=2) has been to project P1(ID=1) and transferred 16 tons and P3(ID=3) transferring 3 tons.
My tblTransfer looks like this:
ID | Asset | Project | Transfer
1 | 1 | 1 | 10
2 | 1 | 2 | 14
3 | 1 | 3 | 5
4 | 2 | 1 | 16
5 | 2 | 3 | 3
And I want my query to show this:
Asset Serial | Total Transfers
Asset 1 | 29
Asset 2 | 19
==============================
Hope this is possible. Appreciate any help or inputs!
I have 3 tables. One table is for my assets, one table is for different projects my assets can be assigned to, and a third table linking each project and asset and lists material transferred by that asset on that project, also a many to many relationship.
tblAsset.ID is PK in tblAsset
tblAsset.Serial contains the serial number of the assets
tblProject.ID is PK in tblProject
tblTransfer.Project is FK linked to tblProject.ID
tblTransfer.Asset is FK linked to tblAsset.ID
tblTransfer.Transfers lists how much material istransferred by my asset on that project.
What i want to do is create a query that show the Serial of each asset, and sums the transported material of all the projects it has been to.
===========================
Example:
Asset1 (ID=1) has been to project P1(ID=1) and transferred 10 tons, P2 (ID=2)transferring 14 tons, and P3(ID=3) transferring 5 tons.
Asset2(ID=2) has been to project P1(ID=1) and transferred 16 tons and P3(ID=3) transferring 3 tons.
My tblTransfer looks like this:
ID | Asset | Project | Transfer
1 | 1 | 1 | 10
2 | 1 | 2 | 14
3 | 1 | 3 | 5
4 | 2 | 1 | 16
5 | 2 | 3 | 3
And I want my query to show this:
Asset Serial | Total Transfers
Asset 1 | 29
Asset 2 | 19
==============================
Hope this is possible. Appreciate any help or inputs!