日期:2014-05-18 浏览次数:20527 次
where (@thbzhi@ = 0 and t1.Fheadselfd0138=40183 AND t1.frob=1) or (t1.Fheadselfd0138=40184 and t1.frob=2)
------解决方案--------------------
select
t1.Fbillno 单据号,
t1.fdate 制单时间,
'杨帆' 制单人,
'2.99' 部门,
'02.06.02' 业务员,
kehu.f_108 仓库助记码,
'转库' 收发类别,
@thbzhi@ 退货标志,
sp.disfnumber 厂商编码,
sp.fname 存货名称,
t2.fqty 数量,
(case when T2.fentryselfb0157 is not null then T2.fentryselfb0157 else t2.fentryselfd0146 end) 建议零售价
from
(SELECT * from icstockbill
where fdate between ******** and ########
and ftrantype in(21,41)
and fsupplyid is not null
and ((@thbzhi@ = 0 and t1.Fheadselfd0138=40183 AND t1.frob=1) or (t1.Fheadselfd0138=40184 and t1.frob=2))) t1
--根据退货标志的不同,取icstockbill中的相应的数据
left outer join icstockbillentry t2
on t1.finterid=t2.finterid
left outer join t_organization kehu
on t1.fsupplyid=kehu.fitemid
left outer join Lch_icitem sp
on t2.fitemid = sp.fitemid
where kehu.fnumber between *CustNo* and #CustNo#