Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 IssuedQuantityfrom Transactions.TransactionBaseMainwhere 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 -- ,IssuedQuantityOrder by FullItemName,Region -- ,IssuedQuantity