select num1+num2 as num ,a.type
from
(select sum(num1)as num1,type from t2
where t2.date >'2008-2-2'and t2.date <'2008-3-4'
group by type) as a
join
(select sum(num2)as num2,type from t3
where t3.date >'2008-2-2'and t3.date <'2008-3-4'
group by type )as b
on a.type=b.type
*************
num type
65 in
88 out
*************
select num1+num2 as num ,a.type
from
(select sum(num1)as num1,type from t2
where t2.date >'2008-3-4'and t2.date <'2008-11-02'
group by type) as a
join
(select sum(num2)as num2,type from t3
where t3.date >'2008-3-4'and t3.date <'2008-11-02'
group by type )as b
on a.type=b.type
*************
num type
122 in
21 out
*************
from
(select sum(num1)as num1,type from t2
where t2.date >'2008-2-2'and t2.date <'2008-3-4'
group by type) as a
join
(select sum(num2)as num2,type from t3
where t3.date >'2008-2-2'and t3.date <'2008-3-4'
group by type )as b
on a.type=b.type
*************
num type
65 in
88 out
*************
select num1+num2 as num ,a.type
from
(select sum(num1)as num1,type from t2
where t2.date >'2008-3-4'and t2.date <'2008-11-02'
group by type) as a
join
(select sum(num2)as num2,type from t3
where t3.date >'2008-3-4'and t3.date <'2008-11-02'
group by type )as b
on a.type=b.type
*************
num type
122 in
21 out
*************
VFP技术交流,QQ群:20452307
欢迎您!