Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 summing question

Author  Topic 

sturner333
Starting Member

22 Posts

Posted - 2014-10-03 : 14:25:35
I have 2 tables.
table1 is projects with unique id
table2 is a bill of material(BOM) for those projects
each line item in the BOM has a column that corresponds to the project it belongs to. It also has a column that tells which of 3 buildings it is stored.

I would like to have know the select statement for a running total cost(another column) for each each project by which building they come from.

BOMprojNumbr(T2) buildingNumber(T2) partCost(T2)
---------------- ----------------- -------------
1 2 $5
1 2 $3
1 3 $9
1 1 $33
2 3 $22
2 1 $7
2 1 $6
2 2 $89

so i would have a result that would tell me for project2 building 1 the total is $13.

Thanks for the help



gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-10-03 : 14:33:55
select sum(partCost)
from table1
group by BOMprojNumber, buildingNumber
Go to Top of Page
   

- Advertisement -