+ -
当前位置:首页 → 问答吧 → 行合并的问题,求解

行合并的问题,求解

时间:2011-12-15

来源:互联网

假如有一张这样的表
orderId orderSummoney invoiceId invoiceDate invoiceMoney payId paydate payMoney
001 10000 FP001 2011-11-11 2000 NULL NULL NULL 
001 10000 FP002 2011-11-12 3000 NULL NULL NULL 
001 10000 FP003 2011-11-13 5000 NULL NULL NULL 
001 10000 NULL NULL NULL P002 2011-11-12 3000
001 10000 NULL NULL NULL P003 2011-11-12 7000

我想到到这样一个结果 
orderId orderSummoney invoiceId invoiceDate invoiceMoney payId payDate payMoney
001 10000 FP001 2011-11-11 2000 P002 2011-11-12 3000
001 10000 FP002 2011-11-12 3000 P003 2011-11-12 7000
001 10000 FP003 2011-11-13 5000 NULL NULL NULL 

不知道怎么弄?

作者: tanweizlf   发布时间: 2011-12-15

没有看清楚按照什么规则来合并?

作者: fredrickhu   发布时间: 2011-12-15

简单说明一下
a b c d 
a1 b1 null null
a1 b2 null null
a1 b3 null null
a1 null c1 d1 
a1 null c2 d2
我想变成
a b c d
a1 b1 c1 d1
a1 b2 c2 d2
a1 b3 null null

原来c d 字段前几行是NULL
我想把c d 字段 后面有内容的往上移

作者: tanweizlf   发布时间: 2011-12-15

这种不是数据库的思路
虽然硬要做可以做
建议换思路
引用 2 楼 tanweizlf 的回复:
简单说明一下
a b c d
a1 b1 null null
a1 b2 null null
a1 b3 null null
a1 null c1 d1
a1 null c2 d2
我想变成
a b c d
a1 b1 c1 d1
a1 b2 c2 d2
a1 b3 null null

原来c d 字段前几行是NULL
我想把c d 字段 后面有内容的往上移

作者: geniuswjt   发布时间: 2011-12-15

楼主是按什么方法得出的结果集

作者: pengxuan   发布时间: 2011-12-15