SQL 服务器 2012 - 转换销售订单行数据以进行 knime 购物篮分析
SQL server 2012 - convert sales order line data for knime market basket analysis
我正在尝试阅读 knime 中的 table 以进行购物篮分析。为此,我需要来自 SQL 服务器 2012 的销售订单行数据,格式如下:具有 space 串联项目的单列。
示例:
ordNo itemNo
x a1
x c2
y a1
y b4
y r1
以下内容:
col0
a1 c2
a1 b4 r1
您可以使用 FOR XML
子句:
select distinct stuff ((select distinct ' '+ t1.itemno
from table t1
where t1.ordno = t.ordno
for xml path('')
), 1, 1, ''
) as [col0]
from table t;
我正在尝试阅读 knime 中的 table 以进行购物篮分析。为此,我需要来自 SQL 服务器 2012 的销售订单行数据,格式如下:具有 space 串联项目的单列。 示例:
ordNo itemNo
x a1
x c2
y a1
y b4
y r1
以下内容:
col0
a1 c2
a1 b4 r1
您可以使用 FOR XML
子句:
select distinct stuff ((select distinct ' '+ t1.itemno
from table t1
where t1.ordno = t.ordno
for xml path('')
), 1, 1, ''
) as [col0]
from table t;