select a.GoodsName,'采购收货',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotGoodsInDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotGoodsIn WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
UNION
select a.GoodsName,'销售出货',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotGoodsOutDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotGoodsOut WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
UNION
select a.GoodsName,'产品入库',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotDyeInDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotDyeIn WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
UNION
select a.GoodsName,'领用出库',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotDyeOutDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotDyeOut WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
ORDER BY b.AddDate
UNION
select a.GoodsName,'销售出货',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotGoodsOutDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotGoodsOut WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
UNION
select a.GoodsName,'产品入库',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotDyeInDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotDyeIn WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
UNION
select a.GoodsName,'领用出库',a.BillCode,a.Price,a.RNumber,a.RMoney,a.Pccode,b.AddDate,b.CustName from (SELECT * FROM T_DepotDyeOutDetail WHERE GoodsName='涤丝类') AS a JOIN (SELECT * FROM T_DepotDyeOut WHERE AddDate>='2007-01-01' and AddDate<='2009-01-01' AND Custname ='杭州金典布业有限公司') AS b ON a.BillCode = b.Billcode
ORDER BY b.AddDate