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.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2001-09-03 : 20:40:15
|
Gregor J. Rothfuss writes "i have a table with the following fields:stock-----idproduct_idlocation_idstocktype_idquantityi want to calculate the quantity of stock for each product at each location. stock type indicates if it is a stock addition or a stock reduction.the formula would look somewhat like this:quantity on stock for a product = sum(stock entries of this product with type = addition) - sum(stock entries of this product with type reduction)i want to display the results like this:product|location|#a loc1 23a loc2 14b loc1 9 i tried some approaches with grouping and subselects, but that led me nowhere.i think i could hack something together with vb, but i'd like this to scale, so i'd prefer a t-sql solution." |
|
|
|
|
|