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 |
huddy1985
Starting Member
6 Posts |
Posted - 2014-07-22 : 17:30:17
|
Hi all, I have come to a hurdle creating a daily report. I have one table (1) that displays worksorders like 'W-010111' and quantity complete (output totals)and another table (2) that displays transactions (issued stock) which I intend to use as input totals. In table 2 my query produces several rows because the users are issuing stock periodically so although the works order id (W-010111) is there in one of the columns its displayed several times with different qty's as expected. What I want to do is sum all of these where it equals the column W-010111 and join into the first table. I am trying to achieve this for all works orders not only one which is why I'm struggling. Please help!!! :) I can send sample data from the tables if need be. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2014-07-22 : 17:40:10
|
[code]SELECT T1.WorkOrderId, SUM(T2.IssuedStock) AS TotalStockFROM Table1 T1 LEFT JOIN Table2 T2 ON T1.WorkOrderId = T2.WorkOrderIdGROUP BY T1.WorkorderId; [/code] |
|
|
huddy1985
Starting Member
6 Posts |
Posted - 2014-07-22 : 17:45:30
|
Thanks alot :) |
|
|
|
|
|