sql语句关联问题(急)
select e.Fname as 业务员,en.fentryselfb0158 as 销售收入
from icstockbillentry as en inner join icstockbill as b on en.Finterid = b.Finterid
left join t_emp as e on e.Fitemid = b.Fempid
select e.Fname as 业务员,convert(money,(case when a.Faccountid = 1114 then vou.FamountFor else 0 end)) as '油款费',
from t_voucherentry as vou inner join t_account as a on a.Faccountid = vou.Faccountid
left join t_itemdetail as it on it.Fdetailid = vou.Fdetailid
left join t_emp as e on e.Fitemid = it.F3
2条语句 想拼成一个。但是不管用 inner 还是left 还是 right (join)数据就都关联上了。
想要的结果是销售收入和业务员关联,
油款费和业务员关联。
但是合成一个表的时候不想让销售收入、油款费一起关联业务员显示。
高手帮帮!!急
------解决方案--------------------select A.业务员,销售收入 ,油款费 from
(
select e.Fname as 业务员,en.fentryselfb0158 as 销售收入
from icstockbillentry as en inner join icstockbill as b on en.Finterid = b.Finterid
left join t_emp as e on e.Fitemid = b.Fempid
) A
inner join
(
select e.Fname as 业务员,convert(money,(case when a.Faccountid = 1114 then vou.FamountFor else 0 end)) as '油款费',
from t_voucherentry as vou inner join t_account as a on a.Faccountid = vou.Faccountid
left join t_itemdetail as it on it.Fdetailid = vou.Fdetailid
left join t_emp as e on e.Fitemid = it.F3
) B
on A.业务员=B.业务员
------解决方案--------------------楼主,这样提问题没人能给你解决,
转帖到sql版,把表关系都写清楚才行