select f.fbillno , f.fheadselfs0169,
f.fdate , f.fcheckdate ,f.fywlname , f.fbmname ,f.fcustname, f.finterid,f.fentryid,
j.fnumber ,j.fname ,j.fmodel, f.fqty , f.fddstockqty , f.fdddate , f.fyjdate , f.fentryselfs0178 , f.fentryselfs0179 ,
l.fpobillno , l.fsupname , l.fcgname ,l.fcgdate , l.fcgcheckdate,
l.fqty as fcgqty, l.fcgjhdate , l.fcgyjdate , l.fcgstockqty , l.fentryselfp0267 , l.fentryselfp0268 ,
h.fbillno as fwobillno ,h.fcommitdate , h.fauxqty , dateadd(dd,-5,h.fplanfinishdate) as fwoyjdate , h.fplanfinishdate ,h.fstockqty as fwostockqty , h.fheadselfj01117 , h.fheadselfj01118
from ( select a.fbillno ,a.fheadselfs0169, a.fdate , a.fcheckdate ,c.fname as fywlname , e.fname as fbmname ,d.fname as fcustname, a.finterid,b.fentryid,
b.fitemid, b.fqty , b.fstockqty as fddstockqty , b.fdate as fdddate , b.fentryselfs0178 , b.fentryselfs0179 ,dateadd(dd,-6,b.fdate) as fyjdate
from