SQL Server: Cross-tabulation, please help

Posted by user335160 on Stack Overflow See other posts from Stack Overflow or by user335160
Published on 2011-01-06T09:00:29Z Indexed on 2011/01/06 9:54 UTC
Read the original article Hit count: 230

Filed under:

I want to achieve the results shown in the attached image. The table structure and data are:

Table relationship:

Facility Limit -> one to many -> Facility Sub Limit

Tables structure and data

Facility Limit

Id   OverallIBLimitId    Product Type
1        1                   RPA
2        1                   CG
3        2                   RPA
4        3                   CG   

Facility Sub Limit

Id FacilityLimitId  Sub-Limit Type      Amount         Tenor     Status     Status Date
1      1             RPA at max      2,000,0000.00  2 months  Approved   January 5, 2011
2      1             Oil              3,000,0000.00  3 yrs     Approved   January 5, 2011
3      2             CG at minor    4,000,0000.00  1 yr      Approved   January 5, 2011
4      2             CG at max      5,000,0000.00  6 months  Approved   January 5, 2011
5      2             Flood Component 1  5,000,0000.00  6 months  Approved   January 5, 2011
6      2             Flood Component 2  6,000,0000.00  3 yrs     Approved   January 5, 2011
7      3             RPA at minor    1,000,0000.00  6 months  Approved   January 5, 2011
8      4             One-Off     1,000,0000.00  6 months  Approved   January 5, 2011

alt text

© Stack Overflow or respective owner

Related posts about sql-server