求大神再赐于一SQL
A表
DYEARMONTHPK_CORPCWAREHOUSEIDCINVENTORYIDCINVBASIDDATEINDATEOUT
2012-0210021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP100
2012-0210021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP70
2012-0410021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP2510
2012-0510021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP03
2012-0710021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP03
2012-0710021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP1310
2012-0810021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP09
2012-0910021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP152
2012-1010021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP02
2012-1010021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP100
2012-1110021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP03
2012-1110021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP08
2012-1210021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP03
B表
DYEARMONTHPK_CORPCWAREHOUSEIDCINVENTORYIDCINVBASIDQICHU
2012-0110021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP7
2012-0110021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP10
2012-0310021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP15
2012-0410021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP-3
2012-0610021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP-3
2012-0610021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP3
2012-0710021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP-9
2012-0810021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP13
2012-0910021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP-2
2012-0910021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP10
2012-1010021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP-8
2012-1010021002F8100000000003ZA0001F810000000006G5Z0001F8100000000066IP-3
2012-1110021002F8100000000003ZB0001F810000000006G5Z0001F8100000000066IP7
两表关键,应该A left join B
现在,如果B.DYEARMONTH<A.DYEARMONTH,则将B表的qichu值汇总放入A表
如A表的2012-02 qichu应该是分CWAREHOUSEID,为对应两条
2012-02 1002F8100000000003ZA 10
2012-02 1002F8100000000003ZB 7
2012-04 1002F8100000000003ZA 10+15=25
2012-05.。。。。
2012-07 1002F8100000000003ZA 10+15+(-3)=19
2012-07 1002F8100000000003ZB 7+3=10
依次下去,
求大神解答,非常感谢!!!
注意是oracle数据!!
[解决办法]
关联条件是A.DYEARMONTH=B.DYEARMONTH?
那 B.DYEARMONTH<A.DYEARMONTH...
[解决办法]
看起来很嚣张的样子。。。。围观
[解决办法]
唐诗不才,没有看懂. 建议举例时,去掉一些无关的列.