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
 i need to group by adding the quantity

Author  Topic 

xcoder56
Starting Member

1 Post

Posted - 2014-12-22 : 10:32:37
HI I Have the following query
Select FullItemName,
Region, IssuedQuantity
from Transactions.TransactionBaseMain
where EnvironmentID = 34
and ModeID=2 and UnitOfIssueID=73 AND itemid=5605 and TransactionType in ('Issue')
and DATEDIFF(DD,TransactionDate,GETDATE())<30
Group by FullItemName,Region,IssuedQuantity
Order by FullItemName,Region,IssuedQuantity


i need to group the IssuedQuantity by region. (Add up the IssuedQuantity for the region)
help pls

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2014-12-22 : 11:57:47
so...


Select FullItemName,
Region, sum(IssuedQuantity) -- aggregate IssuedQuantity
from Transactions.TransactionBaseMain
where EnvironmentID = 34
and ModeID=2 and UnitOfIssueID=73 AND itemid=5605 and TransactionType in ('Issue')
and DATEDIFF(DD,TransactionDate,GETDATE())<30
Group by FullItemName,Region -- ,IssuedQuantity
Order by FullItemName,Region -- ,IssuedQuantity
Go to Top of Page
   

- Advertisement -