代码之家  ›  专栏  ›  技术社区  ›  Andy

在矩阵控件中反转嵌套列组的标题行

  •  1
  • Andy  · 技术社区  · 14 年前

    在矩阵控件中,我按“大小”对列进行分组,然后按“颜色”对列进行分组。结果表如下所示:

    我需要反转标题行,因此表如下所示:

    子组中的值应显示在上面 '.结果表如下所示:

    default grouping

    我需要反转标题行,因此表如下所示:

    grouping

    子组中的值应显示 在上面 父组中的相应值。

    1 回复  |  直到 13 年前
        1
  •  0
  •   D.S.    14 年前

    with CTE (Color, Size, CSGroup, Amt) As (
    select 'Red' As color, 'Small' as size, 'RedSmall' as CSGroup, 1 as Amt union all
    select 'Red' As color, 'Small' as size, 'RedSmall' as CSGroup, 1 as Amt union all
    select 'Red' As color, 'Medium' as size,'RedMedium' as CSGroup, 1 as Amt union all
    select 'Red' As color, 'Medium' as size, 'RedMedium' as CSGroup, 1 as Amt union all
    select 'Red' As color, 'Medium' as size, 'RedMedium' as CSGroup, 1 as Amt union all
    select 'Red' As color, 'Small' as size, 'RedSmall' as CSGroup, 1 as Amt union all
    
    select 'Yellow' As color, 'Small' as size, 'YellowSmall' as CSGroup ,1 as Amt union all
    select 'Yellow' As color, 'Small' as size, 'YellowSmall' as CSGroup ,1 as Amt union all
    select 'Yellow' As color, 'Large' as size, 'YellowLarge' as CSGroup ,1 as Amt union all
    select 'Yellow' As color, 'Large' as size, 'YellowLarge' as CSGroup ,1 as Amt union all
    select 'Yellow' As color, 'Large' as size, 'YellowLarge' as CSGroup ,1 as Amt union all
    select 'Yellow' As color, 'Medium' as size, 'YellowMedium' as CSGroup ,1 as Amt union all
    select 'Yellow' As color, 'Medium' as size, 'YellowMedium' as CSGroup ,1 as Amt union all
    
    select 'Blue' As color, 'Medium' as size, 'BlueMedium' as CSGroup, 1 as Amt union all
    select 'Blue' As color, 'Medium' as size, 'BlueMedium' as CSGroup, 1 as Amt union all
    select 'Blue' As color, 'Medium' as size, 'BlueMedium' as CSGroup, 1 as Amt union all
    select 'Blue' As color, 'Small' as size, 'BlueSmall' as CSGroup, 1 as Amt union all
    select 'Blue' As color, 'Large' as size, 'BlueLarge' as CSGroup, 1 as Amt union all
    select 'Blue' As color, 'Large' as size, 'BlueLarge' as CSGroup, 1 as Amt union all
    
    select 'Green' As color, 'Medium' as size, 'GreenMedium' as CSGroup, 1 as Amt union all
    select 'Green' As color, 'Medium' as size, 'GreenMedium' as CSGroup, 1 as Amt union all
    select 'Green' As color, 'Large' as size, 'GreenLarge' as CSGroup, 1 as Amt union all
    select 'Green' As color, 'Large' as size, 'GreenLarge' as CSGroup, 1 as Amt union all
    select 'Green' As color, 'Large' as size, 'GreenLarge' as CSGroup, 1 as Amt union all
    select 'Green' As color, 'Small' as size, 'GreenSmall' as CSGroup, 1 as Amt union all
    select 'Green' As color, 'Small' as size, 'GreenSmall' as CSGroup, 1 as Amt)
    Select Color, Size, SUM(Amt) As Amount From CTE group by Color, Size
    

    CSGroup

    =Fields!size.Value & Fields!color.Value

    =Fields!size.Value

    =Fields!color.Value

    =First(Fields!Size.Value)

    =Sum(Fields!Amount.Value)

    Dataset1

    Grouping Example