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
 SQL Server Development (2000)
 CrossTab Problem

Author  Topic 

tchinedu
Yak Posting Veteran

71 Posts

Posted - 2006-06-22 : 17:00:59
Please help guys,

I need to build a crosstab that looks as follows

AttributeName________Grp1__________Grp2________Grp3....
TotalLoans----------------200--------------400-------------600
TotalFixed----------------120--------------280-------------510
TotalFloat-----------------80--------------120--------------90
Avg_Balance-------------$12000---------$14000-----------$13000
Avg_InterestRate----------8.9%-----------6.7%------------9.8%
...etc

each of the columns is calculated based on the Grp#
eg. TotalLoans = Sum(Balance) where grp=1
TotalFixed = Sum(balance) where grp=1 and InterestRate=Fixed
etc

the DDL for the table is straighforward, I have columns that list loan details including groupingID
:
LoanNum,
Balance,
InterestRate,
InterestType --i.e Fixed or float
BorrowerName,
BorrowerAddr,
GroupId,
PropertyTye,
etc.

PS:
I do not know the number of different groups I have and the labels I'm using for the AttributeName column is not stored in the DB, this is just a human readable label to describe the row and make the info easier for mgmt to understand....so the rows will be constant, but the columns, i.e number of groups in the table can increase or decrease

Please help


madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-23 : 02:24:53
Read about Cross-tab Reports in sql server help file
Also refer http://weblogs.sqlteam.com/jeffs/archive/2005/05.aspx

Madhivanan

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

- Advertisement -