考虑一下,我有一张table,比如:
表a
+--------+--------+--------+-----+
| code_1 | code_2 | code_3 | qty |
+--------+--------+--------+-----+
| 0.5 | 0.6 | 0.2 | 3 |
+--------+--------+--------+-----+
| 0.8 | 1.2 | 3.2 | 4 |
+--------+--------+--------+-----+
| 3.0 | 2.2 | 0.4 | 7 |
+--------+--------+--------+-----+
还有一个参考表,比如:
参考表
+--------+--------+
| id | code |
+--------+--------+
| 1 | code_1 |
+--------+--------+
| 2 | code_2 |
+--------+--------+
| 3 | code_3 |
+--------+--------+
现在,我想得到如下输出:
输出表
+--------+--------+--------+
| id | value | qty |
+--------+--------+--------+
| 1 | 0.5 | 3 |
+--------+--------+--------+
| 2 | 0.6 | 3 |
+--------+--------+--------+
| 3 | 0.2 | 3 |
+--------+--------+--------+
| 1 | 0.8 | 4 |
+--------+--------+--------+
| 2 | 1.2 | 4 |
+--------+--------+--------+
| 3 | 3.2 | 4 |
+--------+--------+--------+
| 1 | 3.0 | 7 |
+--------+--------+--------+
| 2 | 2.2 | 7 |
+--------+--------+--------+
| 3 | 0.4 | 7 |
+--------+--------+--------+
注意:-引用表在mysql数据库中,表a在mssql数据库中。我使用pentaho pdi从两个表中获取数据(在不同的数据库中,通过“表输入”步骤)。
如何在pentaho pdi-spoon(etl)中获得输出表?
另外,这在sql中是如何实现的(如果两个表都在同一个mssql数据库中)?
提前感谢:)
1条答案
按热度按时间g2ieeal71#
在sql server中,您可以使用横向联接,即关键字
apply
: