28,406
社区成员
发帖
与我相关
我的任务
分享select 商品名称,sum(采购金额),sum(销售金额),sum(销售金额)-sum(采购金额) as 盈利
from (
select 表1.商品名称,表2.采购金额,0 as 销售金额
from 表1 inner join 表2 on 表1.ID=表2.对应表1ID
where 采购日期 between '2009年2月1日' and '2009年9月1日'
union all
select 表1.商品名称,0 as 采购金额,表3.销售金额
from 表1 inner join 表3 on 表1.ID=表3.对应表1ID
where 销售日期 between '2009年2月1日' and '2009年9月1日'
) t
group by 商品名称