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.Fempidselect 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)数据就都关联上了。
想要的结果是销售收入和业务员关联,
油款费和业务员关联。
但是合成一个表的时候不想让销售收入、油款费一起关联业务员显示。高手帮帮!!急
from icstockbillentry as en inner join icstockbill as b on en.Finterid = b.Finterid
left join t_emp as e on e.Fitemid = b.Fempidselect 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)数据就都关联上了。
想要的结果是销售收入和业务员关联,
油款费和业务员关联。
但是合成一个表的时候不想让销售收入、油款费一起关联业务员显示。高手帮帮!!急
解决方案 »
- 急!!Client found response content type of 'text/html', but expected 'text/xml'.
- ibatis框架,mapping问题
- C#怎么获得任意网址发来的消息
- 怎样加Try Catch语句
- 对ListView进行排序时出现如图文件夹与文件混在一起,希望文件夹在上,文件在下
- 多桌面技术问题!做过的,或是高手的请进!
- 高手指點.在線等...問題如下:
- 高分求解,怎么用enterprise library连接Oralce???
- 函数返回值的问题
- 安装调试器问题
- 类变量是引用传递,但有的要加ref是为什么?
- C# 窗口线程join问题,在线等.
(
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
) Ainner 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.业务员
你应该以业务员的基本信息为主表 分别连接 销售收入表和油款表类似这样select 业务员名字,销售收入,油款费 from 业务员基本信息表
left outer join 销售收入表 on 业务员基本信息表.业务员编号=销售收入表.业务员编号
left outer join 油款费 on 业务员基本信息表.业务员编号=油款费 .业务员编号
转帖到sql版,把表关系都写清楚才行