日期:2014-05-17 浏览次数:20405 次
select InDate,Stock.LotNo,Stock.ModelName,Stock.ModelNo,Type,Stock.LotQty,isnull(InQty,0) as InQty,isnull(OutQty,0) as OutQty,StockQty,isnull(StopQty,0) as StopQty,Stock.LotQty-isnull(inqty,0) as Subassy,Remark
from @Stock as Stock left join StockOutStop on Stock.LotNo = StockOutStop.LotNo
left join @StockIn si on si.LotNo= Stock.LotNo and si.ModelNo=stock.ModelNo
left join @StockOut so on so.LotNo=Stock.LotNo and so.ModelNo=stock.ModelNo
where ( StockQty>0 or StockQty<0) or (Stock.LotQty-isnull(inqty,0)>0 or Stock.LotQty-isnull(inqty,0)<0)
or( DATEDIFF(mm,OutDate,getdate())=0
--or(year(OutDate)=year(getdate()) and Month(OutDate)=Month(getDate())
and(StockQty=0 and Stock.LotQty-isnull(inqty,0)=0))