你好。所以我正在使用 PowerPivot 的查询编辑器。我在 PowerPivot 窗口中有两个表,我正在使用表属性选项卡中的查询编辑器对其进行编辑。这些表有不同数量的列,它们有一些共同的列,每个列都包含唯一的列。他们共享的列具有相同的标题名称。我想将一张桌子堆叠在另一张桌子上,同时向原始表格添加新列。
For example:<p></p>
<table><i>TableA</i>
<th>Col1</th><th>Col2</th><th>Col3</th>
<tr><td>A</td><td>B</td><td>C</td>
</tr>
</table><p></p><table><i>TableB</i>
<th>Col1</th><th>Col2</th><th>Col4</th>
<tr><td>D</td><td>E</td><td>F</td>
</tr>
</table><p></p>
<table><i>Combined</i>
<th>Col1</th><th>Col2</th><th>Col3</th><th>Col4</th>
<tr><td>A</td><td>B</td><td>C</td><td>-</td>
</tr>
<tr><td>D</td><td>E</td><td>-</td><td>F</td>
</tr>
<tr>
</table>
<p></p>
示例代码:
SELECT tableA.col1, tableA.col2, tableA.col3, NULL AS col4
FROM [tableA$]
UNION
SELECT tableB.col1, tableB.col2, NULL AS col3, tableB.col4
FROM [tableB$];
我看到一篇使用 NULL AS 来弥补缺失列的帖子,但是一旦我添加它,我就会收到“未检测到列”错误消息。实际上,我正在处理数十张工作表,其中列的范围从 15 到超过 70,行的范围从 300 到 350k,这就是我使用 PowerPivot 的原因。
我通过创建与工作表的连接将工作表导入 PowerPivot。PS 我是 PowerPivot 和查询编辑器的新手。感谢您提前提供任何帮助。