当前位置: 代码迷 >> DB2 >> []DB2 用SQL将一条数据中用逗号隔开的字段分成多条记录
  详细解决方案

[]DB2 用SQL将一条数据中用逗号隔开的字段分成多条记录

热度:8387   发布时间:2013-02-26 00:00:00.0
[求助]DB2 用SQL将一条数据中用逗号隔开的字段分成多条记录
各位大神好,
    小弟遇到一个问题,DB2中如何用。SQL将一条数据中用逗号隔开的字段分成多条记录。
示例如下,
seq(integer)    test(varchar)  customer(varchar)   cinvcode(varchar)  ……
1                 a              4                   2
2                 a,b            3                   2
3                 a,b,c          6                   1
4                 b,c,d,e,f      1                   5

期望结果,
seq(integer)    test(varchar)  customer(varchar)   cinvcode(varchar)  ……
1                 a              4                   2
2                 a              3                   2
2                 b              3                   2
3                 a              6                   1
3                 b              6                   1
3                 c              6                   1
4                 b              1                   5
4                 c              1                   5
4                 d              1                   5
  相关解决方案