2016-07-14 5 views
0

Ich habe einen Bericht in HTML, wo, abhängig von der Organisation, mehr als eine Tabelle angezeigt werden kann, was relativ einfach in HTML war. Jetzt schreibe ich den gleichen Bericht in SSRS.SSRS: Kann ich mehr als eine Tabelle mit demselben Datensatz anzeigen?

Gibt es einen Weg, ich kann etwas wie ein Repeater (wie in ASP.NET) Tabelle kann wiederholt werden, während einzelne Tabelle kann es eigene Daten zur Anzeige haben.

Ich weiß nicht wirklich wo ich anfangen soll. Vielleicht könnte ich 10 Tabellen haben, die auf ähnliche leicht modifizierte Datensätze zeigen, und die Tabelle ausblenden, wenn keine Daten vorhanden sind.

Vielen Dank für

EDIT

Die Abfrage hilft gibt so etwas wie diese:

ID | Organization | Total | col1 | col2 | col3 | col4 | col5 
------------------------------------------------------------- 
1 | Accounting | 10 | 2 | 1 | 3 | 0 | 4 
------------------------------------------------------------- 
2 | Production | 15 | 7 | 0 | 3 | 1 | 4 

nun den Bericht so etwas wie diese

  Accounting 
------------------------------- 
| col1   | 2 (20.00%) | 
-------------------------------- 
| col2   | 1 (10.00%) | 
-------------------------------- 
| col3   | 3 (30.00%) |  
-------------------------------- 
| col4   | 0 (0.00%) | 
-------------------------------- 
| col5   | 4 (40.00%) |  
-------------------------------- 

So eine Tabelle sein aussehen soll, wird für jede Reihe ertrinken.

Antwort

0

Dies ist möglich.

Angenommen, Sie möchten eine Tabelle für jeden Wert in Feld A erstellen, können Sie eine Tabelle mit den Feldern BX erstellen und diese Tabelle in eine Zelle in einer anderen Tabelle einfügen, die dasselbe Dataset verwendet und nach Zeilen gruppiert ist Feld A. Dies wird im Wesentlichen einen Filter für jede Ihrer Untertabellen bereitstellen.

Die Untertabellen werden automatisch an die Breite und Höhe der Zelle in Ihrer "Super-Tabelle" angepasst, aber dies kann (falls gewünscht) vermieden werden, indem Sie die Untertabelle innerhalb eines Rechtecks ​​platzieren und die Rechteck in die Super-Tabelle. Sie werden dann feststellen, dass das Rechteck in der Größe veränderbar ist und der Rest der Zelle mit anderen Rechtecken aufgefüllt werden kann.

Um das Aussehen mehrerer Tabellen zu erstellen, können Sie mit Rahmen usw. herumspielen, so dass die Super-Tabelle nicht mehr sichtbar ist.

Xml für die Daten zur Verfügung gestellt Sie (nur Gehäuse):

<Body> 
    <ReportItems> 
    <Textbox Name="textbox1"> 
     <CanGrow>true</CanGrow> 
     <KeepTogether>true</KeepTogether> 
     <Paragraphs> 
     <Paragraph> 
      <TextRuns> 
      <TextRun> 
       <Value>Report1</Value> 
       <Style> 
       <FontFamily>Tahoma</FontFamily> 
       <FontSize>20pt</FontSize> 
       <FontWeight>Bold</FontWeight> 
       <Color>SteelBlue</Color> 
       </Style> 
      </TextRun> 
      </TextRuns> 
      <Style /> 
     </Paragraph> 
     </Paragraphs> 
     <rd:DefaultName>textbox1</rd:DefaultName> 
     <Height>0.36in</Height> 
     <Width>5in</Width> 
     <Style> 
     <PaddingLeft>2pt</PaddingLeft> 
     <PaddingRight>2pt</PaddingRight> 
     <PaddingTop>2pt</PaddingTop> 
     <PaddingBottom>2pt</PaddingBottom> 
     </Style> 
    </Textbox> 
    <Tablix Name="Tablix2"> 
<TablixBody> 
    <TablixColumns> 
    <TablixColumn> 
     <Width>0.41667in</Width> 
    </TablixColumn> 
    <TablixColumn> 
     <Width>2.19792in</Width> 
    </TablixColumn> 
    <TablixColumn> 
     <Width>0.39583in</Width> 
    </TablixColumn> 
    </TablixColumns> 
    <TablixRows> 
    <TablixRow> 
     <Height>0.25in</Height> 
     <TablixCells> 
     <TablixCell> 
      <CellContents> 
      <Textbox Name="Textbox29"> 
       <CanGrow>true</CanGrow> 
       <KeepTogether>true</KeepTogether> 
       <Paragraphs> 
       <Paragraph> 
        <TextRuns> 
        <TextRun> 
         <Value /> 
         <Style /> 
        </TextRun> 
        </TextRuns> 
        <Style /> 
       </Paragraph> 
       </Paragraphs> 
       <rd:DefaultName>Textbox29</rd:DefaultName> 
       <Style> 
       <Border> 
        <Style>None</Style> 
       </Border> 
       <PaddingLeft>2pt</PaddingLeft> 
       <PaddingRight>2pt</PaddingRight> 
       <PaddingTop>2pt</PaddingTop> 
       <PaddingBottom>2pt</PaddingBottom> 
       </Style> 
      </Textbox> 
      </CellContents> 
     </TablixCell> 
     <TablixCell> 
      <CellContents> 
      <Textbox Name="Textbox31"> 
       <CanGrow>true</CanGrow> 
       <KeepTogether>true</KeepTogether> 
       <Paragraphs> 
       <Paragraph> 
        <TextRuns> 
        <TextRun> 
         <Value /> 
         <Style /> 
        </TextRun> 
        </TextRuns> 
        <Style /> 
       </Paragraph> 
       </Paragraphs> 
       <rd:DefaultName>Textbox31</rd:DefaultName> 
       <Style> 
       <Border> 
        <Color>LightGrey</Color> 
        <Style>None</Style> 
       </Border> 
       <PaddingLeft>2pt</PaddingLeft> 
       <PaddingRight>2pt</PaddingRight> 
       <PaddingTop>2pt</PaddingTop> 
       <PaddingBottom>2pt</PaddingBottom> 
       </Style> 
      </Textbox> 
      </CellContents> 
     </TablixCell> 
     <TablixCell> 
      <CellContents> 
      <Textbox Name="Textbox35"> 
       <CanGrow>true</CanGrow> 
       <KeepTogether>true</KeepTogether> 
       <Paragraphs> 
       <Paragraph> 
        <TextRuns> 
        <TextRun> 
         <Value /> 
         <Style /> 
        </TextRun> 
        </TextRuns> 
        <Style /> 
       </Paragraph> 
       </Paragraphs> 
       <rd:DefaultName>Textbox35</rd:DefaultName> 
       <Style> 
       <Border> 
        <Color>LightGrey</Color> 
        <Style>None</Style> 
       </Border> 
       <PaddingLeft>2pt</PaddingLeft> 
       <PaddingRight>2pt</PaddingRight> 
       <PaddingTop>2pt</PaddingTop> 
       <PaddingBottom>2pt</PaddingBottom> 
       </Style> 
      </Textbox> 
      </CellContents> 
     </TablixCell> 
     </TablixCells> 
    </TablixRow> 
    <TablixRow> 
     <Height>1.41667in</Height> 
     <TablixCells> 
<TablixCell> 
    <CellContents> 
    <Textbox Name="Organization"> 
     <CanGrow>true</CanGrow> 
     <KeepTogether>true</KeepTogether> 
     <Paragraphs> 
     <Paragraph> 
      <TextRuns> 
      <TextRun> 
       <Value /> 
       <Style /> 
      </TextRun> 
      </TextRuns> 
      <Style /> 
     </Paragraph> 
     </Paragraphs> 
     <rd:DefaultName>Organization</rd:DefaultName> 
     <Style> 
     <Border> 
      <Style>None</Style> 
     </Border> 
     <PaddingLeft>2pt</PaddingLeft> 
     <PaddingRight>2pt</PaddingRight> 
     <PaddingTop>2pt</PaddingTop> 
     <PaddingBottom>2pt</PaddingBottom> 
     </Style> 
    </Textbox> 
    </CellContents> 
</TablixCell> 
<TablixCell> 
    <CellContents> 
    <Tablix Name="Tablix1"> 
     <TablixBody> 
     <TablixColumns> 
      <TablixColumn> 
      <Width>1.09896in</Width> 
      </TablixColumn> 
      <TablixColumn> 
      <Width>1.09896in</Width> 
      </TablixColumn> 
     </TablixColumns> 
     <TablixRows> 
      <TablixRow> 
      <Height>0.23611in</Height> 
      <TablixCells> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="Organization1"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>=Fields!Organization.Value</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style> 
          <TextAlign>Center</TextAlign> 
         </Style> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>Organization1</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
        <ColSpan>2</ColSpan> 
       </CellContents> 
       </TablixCell> 
       <TablixCell /> 
      </TablixCells> 
      </TablixRow> 
      <TablixRow> 
      <Height>0.23611in</Height> 
      <TablixCells> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col1"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>col1</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col1</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col6"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>=Fields!col1.Value</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col1</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
      </TablixCells> 
      </TablixRow> 
      <TablixRow> 
      <Height>0.23611in</Height> 
      <TablixCells> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col2"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>col2</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col2</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col21"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>=Fields!col2.Value</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col21</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
      </TablixCells> 
      </TablixRow> 
      <TablixRow> 
      <Height>0.23611in</Height> 
      <TablixCells> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col3"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>col3</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col3</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col31"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>=Fields!col3.Value</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col31</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
      </TablixCells> 
      </TablixRow> 
      <TablixRow> 
      <Height>0.23611in</Height> 
      <TablixCells> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col4"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>col4</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col4</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="Textbox15"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>=Fields!col4.Value</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>Textbox15</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
      </TablixCells> 
      </TablixRow> 
      <TablixRow> 
      <Height>0.23611in</Height> 
      <TablixCells> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="col5"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>col5</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>col5</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
       <TablixCell> 
       <CellContents> 
        <Textbox Name="Textbox18"> 
        <CanGrow>true</CanGrow> 
        <KeepTogether>true</KeepTogether> 
        <Paragraphs> 
         <Paragraph> 
         <TextRuns> 
          <TextRun> 
          <Value>=Fields!col5.Value</Value> 
          <Style /> 
          </TextRun> 
         </TextRuns> 
         <Style /> 
         </Paragraph> 
        </Paragraphs> 
        <rd:DefaultName>Textbox18</rd:DefaultName> 
        <Style> 
         <Border> 
         <Color>LightGrey</Color> 
         <Style>Solid</Style> 
         </Border> 
         <PaddingLeft>2pt</PaddingLeft> 
         <PaddingRight>2pt</PaddingRight> 
         <PaddingTop>2pt</PaddingTop> 
         <PaddingBottom>2pt</PaddingBottom> 
        </Style> 
        </Textbox> 
       </CellContents> 
       </TablixCell> 
      </TablixCells> 
      </TablixRow> 
     </TablixRows> 
     </TablixBody> 
     <TablixColumnHierarchy> 
     <TablixMembers> 
      <TablixMember /> 
      <TablixMember /> 
     </TablixMembers> 
     </TablixColumnHierarchy> 
     <TablixRowHierarchy> 
     <TablixMembers> 
      <TablixMember /> 
      <TablixMember /> 
      <TablixMember /> 
      <TablixMember /> 
      <TablixMember /> 
      <TablixMember /> 
     </TablixMembers> 
     </TablixRowHierarchy> 
     <DataSetName>DataSet1</DataSetName> 
     <Style> 
     <Border> 
      <Style>None</Style> 
     </Border> 
     </Style> 
    </Tablix> 
    </CellContents> 
</TablixCell> 
     <TablixCell> 
      <CellContents> 
      <Textbox Name="Textbox36"> 
       <CanGrow>true</CanGrow> 
       <KeepTogether>true</KeepTogether> 
       <Paragraphs> 
       <Paragraph> 
        <TextRuns> 
        <TextRun> 
         <Value /> 
         <Style /> 
        </TextRun> 
        </TextRuns> 
        <Style /> 
       </Paragraph> 
       </Paragraphs> 
       <rd:DefaultName>Textbox36</rd:DefaultName> 
       <Style> 
       <Border> 
        <Style>None</Style> 
       </Border> 
       <PaddingLeft>2pt</PaddingLeft> 
       <PaddingRight>2pt</PaddingRight> 
       <PaddingTop>2pt</PaddingTop> 
       <PaddingBottom>2pt</PaddingBottom> 
       </Style> 
      </Textbox> 
      </CellContents> 
     </TablixCell> 
     </TablixCells> 
    </TablixRow> 
    </TablixRows> 
</TablixBody> 
     <TablixColumnHierarchy> 
     <TablixMembers> 
      <TablixMember /> 
      <TablixMember /> 
      <TablixMember /> 
     </TablixMembers> 
     </TablixColumnHierarchy> 
     <TablixRowHierarchy> 
     <TablixMembers> 
      <TablixMember> 
      <KeepWithGroup>After</KeepWithGroup> 
      </TablixMember> 
      <TablixMember> 
      <Group Name="Details"> 
       <GroupExpressions> 
       <GroupExpression>=Fields!Organization.Value</GroupExpression> 
       </GroupExpressions> 
      </Group> 
      </TablixMember> 
     </TablixMembers> 
     </TablixRowHierarchy> 
     <DataSetName>DataSet1</DataSetName> 
     <Top>0.36in</Top> 
     <Height>1.66667in</Height> 
     <Width>3.01042in</Width> 
     <ZIndex>1</ZIndex> 
     <Style> 
     <Border> 
      <Style>None</Style> 
     </Border> 
     </Style> 
    </Tablix> 
    </ReportItems> 
    <Height>3.69667in</Height> 
    <Style /> 
</Body> 

Der Datensatz wird:

<DataSets> 
    <DataSet Name="DataSet1"> 
    <Query> 
     <DataSourceName>DataSource1</DataSourceName> 
     <CommandText>SELECT  1 AS ID, 'Accounting' AS Organization, 10 AS Total, 2 AS col1, 1 AS col2, 3 AS col3, 0 AS col4, 4 AS col5 
UNION ALL 
SELECT  2 AS Expr1, 'Production' AS Expr2, 15 AS Expr3, 7 AS Expr4, 0 AS Expr5, 3 AS Expr6, 1 AS Expr7, 4 AS Expr8</CommandText> 
    </Query> 
    <Fields> 
     <Field Name="ID"> 
     <DataField>ID</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="Organization"> 
     <DataField>Organization</DataField> 
     <rd:TypeName>System.String</rd:TypeName> 
     </Field> 
     <Field Name="Total"> 
     <DataField>Total</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="col1"> 
     <DataField>col1</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="col2"> 
     <DataField>col2</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="col3"> 
     <DataField>col3</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="col4"> 
     <DataField>col4</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
     <Field Name="col5"> 
     <DataField>col5</DataField> 
     <rd:TypeName>System.Int32</rd:TypeName> 
     </Field> 
    </Fields> 
    </DataSet> 
</DataSets> 
+0

Bitte beachten Sie die Ergänzung von Informationen, die ich denke, wird dazu beitragen, das Endergebnis vorstellen. – Richard77

+0

Also Feld A wäre Ihr Feld 'Organisation', und Sie würden Ihre Untertabelle mit dem anderen Feld 'Spalte1' usw. erstellen und dann dieses Element in die Zeilengruppierung der Obertabelle einfügen. Ich habe meiner Antwort ein xml hinzugefügt, das Ihre Ausgabe erstellt. –

0

Ich würde Entpivotisierung für diese Aufgabe wie im Skript unter:

--Create the table and insert values as portrayed in the previous example. 
CREATE TABLE pvt (VendorID int, Emp1 int, Emp2 int, 
    Emp3 int, Emp4 int, Emp5 int); 
GO 
INSERT INTO pvt VALUES (1,4,3,5,4,4); 
INSERT INTO pvt VALUES (2,4,1,5,5,5); 
INSERT INTO pvt VALUES (3,4,3,5,4,4); 
INSERT INTO pvt VALUES (4,4,2,5,5,4); 
INSERT INTO pvt VALUES (5,5,1,5,5,5); 
GO 

SELECT * FROM pvt 
--Unpivot the table. 
SELECT VendorID, Employee, Orders 
FROM 
    (SELECT VendorID, Emp1, Emp2, Emp3, Emp4, Emp5 
    FROM pvt) p 
UNPIVOT 
    (Orders FOR Employee IN 
     (Emp1, Emp2, Emp3, Emp4, Emp5) 
)AS unpvt; 
GO 

enter image description here

Von: https://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx

Verwandte Themen