我有这样的数据:
开始日期 结束日期 金额 INVNO
- 2012-11-07 09:23:48.000 2012-11-07 09:23:59.000 0.00000000 000000000002012
- 2012-11-07 09:23:59.000 2012-11-07 10:14:02.000 0.00000000 000000000002012
- 2012-11-07 10:14:02.000 2012-11-07 10:15:13.000 0.00000000 000000000002012
- 2012-11-07 10:15:13.000 2012-11-07 10:34:08.000 0.00000000 000000000002012
- 2012-11-07 10:34:08.000 2012-11-07 11:09:33.000 4000.00000000 000000000002012
- 2012-11-07 11:09:33.000 2012-11-07 11:10:35.000 4000.00000000 000000000002012
我希望它们合并成一行,如下所示:
- 2012-11-07 09:23:48.000 2012-11-07 11:10:35.000 8000.00000000 000000000002012 STARTDATE 字段中第一行的开始日期,ENDDATE 字段中最后一行的结束日期和 AMOUNT 字段中金额的总和。
谢谢你的帮助
ps:但如果有数据开始日期与上一行的结束日期不同,则必须开始新行。像这样:
- 2012-11-07 09:23:48.000 2012-11-07 09:23:59.000 20.00000000 000000000002012
- 2012-11-07 09:23:59.000 2012-11-07 10:14:02.000 30.00000000 000000000002012
- 2012-11-07 10:16:09.000 2012-11-07 10:19:13.000 40.00000000 000000000002012
- 2012-11-07 10:19:13.000 2012-11-07 10:34:08.000 50.00000000 000000000002012
应该是这样的:
- 2012-11-07 09:23:48.000 2012-11-07 10:14:02.000 50.00000000 000000000002012
- 2012-11-07 10:16:09.000 2012-11-07 10:34:08.000 90.00000000 000000000002012