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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Adding Aggregate Data

Author  Topic 

tecknowledge1164
Starting Member

25 Posts

Posted - 2006-04-18 : 15:57:28
I have a report that is based on a SQL statement as follows: SELECT Category, ItemNumber, ItemCost, SumOfQuantity, Description, (SumOfQuantity * ItemCost) AS Total FROM viwInventory WHERE Category Like [ComboBoxSelection] ORDER BY Category. I need to add three columns to each row in the report, all summing the Quantity field of a table WHTransactions where the Type = 1, 2, and 3, i.e. Sum(Quantity) as Received where Type = 1, Sum(Quantity) as BeginningBalance where Type = 2, Sum(Quantity) as Shipped where Type = 3. The join field is viwInventory.ID = WHTransactions.WHInventoryID.

I am not sure how to construct the SQL statement to accomplish this. I can't really change the view that the report uses since it is used in other places, so I will need to modify the SQL in the report. Any suggestions would be appreciated.

TIA

Bob Thompson

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-04-18 : 16:13:17
Read the section on CROSSTAB reports in Books Online.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-19 : 03:53:38
or

http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

tecknowledge1164
Starting Member

25 Posts

Posted - 2006-04-19 : 14:52:22
quote:
Originally posted by blindman

Read the section on CROSSTAB reports in Books Online.



That was all it took, many thanks.

Bob
Go to Top of Page
   

- Advertisement -