insert into B select user_id,sum(money) from ( select * from A_201010 union all select * from A_201009 union all select * from A_201008 union all select * from A_201007 union all ... union all select * from A_201001 ) t where ordertime>=CURDATE()-interval 90 day group by user_id;
select user_id,sum(money)
from (
select * from A_201010
union all
select * from A_201009
union all
select * from A_201008
union all
select * from A_201007
union all
...
union all
select * from A_201001
) t
where ordertime>=CURDATE()-interval 90 day
group by user_id;
谢谢您的答案,ACMAIN_CHM真的是很牛啊,不过我这边数据量很大的,采用您的方法速度比较慢,我写了shell脚本采用了每个表单独计算再相加的方法,不过比较复杂