在Oracle中转置表

时间:2018-06-07 09:44:57

标签: sql oracle

原始表格如下所示



<h2>Original table:</h2>
<table border="1" style="width:100%" cellpadding="0" cellspacing="0">
<tr style="background-color:#aaa"><th>S.No</th><th>Name</th><th>No1</th><th>No2</th></tr>
<tr><th>1</th><th>Test1</th><th>10</th><th>50</th></tr>
<tr><th>2</th><th>Test2</th><th>20</th><th>30</th></tr>
<tr><th>3</th><th>Test3</th><th>40</th><th>20</th></tr>
<tr><th>4</th><th>Test4</th><th>80</th><th>90</th></tr>
</table>
&#13;
&#13;
&#13;

我想将上表转换成下表。

&#13;
&#13;
<h2>Output:</h2>
<table border="1" style="width:100%" cellpadding="0" cellspacing="0">
<tr style="background-color:#aaa"><th>S.No</th><th>Test1</th><th>Test2</th><th>Test3</th><th>Test4</th></tr>
<tr><th>1</th><th>10</th><th>20</th><th>40</th><th>80</th></tr>
<tr><th>2</th><th>50</th><th>30</th><th>20</th><th>90</th></tr>
</table>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:1)

您想要解开并重新转动。这是一种方法:

 StatefulBeanToCsv btcsv = new StatefulBeanToCsvBuilder(writer)
            .withSeparator(Constants.HASH_SEPARATOR)
            .withMappingStrategy(headerColumnNameMappingStrategy)
            .build();