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 |
|
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 followsAttributeName________Grp1__________Grp2________Grp3....TotalLoans----------------200--------------400-------------600TotalFixed----------------120--------------280-------------510TotalFloat-----------------80--------------120--------------90Avg_Balance-------------$12000---------$14000-----------$13000Avg_InterestRate----------8.9%-----------6.7%------------9.8%...etceach of the columns is calculated based on the Grp#eg. TotalLoans = Sum(Balance) where grp=1 TotalFixed = Sum(balance) where grp=1 and InterestRate=Fixedetcthe DDL for the table is straighforward, I have columns that list loan details including groupingID:LoanNum,Balance,InterestRate,InterestType --i.e Fixed or floatBorrowerName,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 decreasePlease help |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|