select * from (SELECT SaleBillVouch.cSBVCode as 单据号, SaleBillVouch.dDate AS 销售日期,SaleBillVouch.cCusName AS 客户, SaleBillVouchs.cInvCode AS 存货编码, Inventory.cInvName AS 存货名称,inventory.cInvStd as 规格型号, SaleBillVouchs.iQuantity AS 数量,SaleBillVouchs.iNum AS 件数, salebillvouchs.iTaxUnitPrice as 含税单价,salebillvouchs.isum as 销售金额, IA_Subsidiary.iAOutPrice as 成本金额 FROM SaleBillVouch with(nolock) inner JOIN SaleBillVouchs with(nolock) ON SaleBillVouchs.SBVID = SaleBillVouch.SBVID inner JOIN Customer with (nolock) ON SaleBillVouch.cCusCode = Customer.cCusCode inner JOIN Inventory with (nolock) ON SaleBillVouchs.cInvCode = Inventory.cInvCode inner join IA_Subsidiary with (nolock) ON salebillvouchs.idlsid = IA_Subsidiary .idlsid and salebillvouchs.cInvCode = IA_Subsidiary.cInvCode where YEAR(salebillvouch.dDate )>=(2019) order by 销售日期) where SaleBillVouch.cCusName = "${company}" and SaleBillVouch.cCusName=SaleBillVouch.cSBVCode |