日期:2014-05-18 浏览次数:20686 次
createPROCEDURE [dbo].[StorSaleReportDateSet] -- Add the parameters for the stored procedure here @StartTime dateTime, @EndTime dateTime, @flag int = 0 output AS BEGIN SELECT product.productCode, product.productName, max(product.unitName) as unitName, SUM(proStorBill.quantity) as StorQuantity, SUM(proSaleBill.quantity) as SaleQuantity, AVG(product.storQuantity) as remainQuantity from product left join proStorBill on product.productName=proStorBill.productName and proStorBill.storDate is not null and proStorBill.storDate<@EndTime and proStorBill.storDate>@StartTime left join proSaleBill on product.productName=proSaleBill.productName and proSaleBill.saleDate is not null and proSaleBill.saleDate<@EndTime and proSaleBill.saleDate>@StartTime where (proStorBill.storDate<@EndTime and proStorBill.storDate>@StartTime) or (proSaleBill.saleDate<@EndTime and proSaleBill.saleDate>@StartTime) group by product.productName,product.productCode if (@@ROWCOUNT>0) Set @flag = 1 else Set @flag = 0 END
exec [StorSaleReportDateSet] '2012/5/27 0:00:00','2012/6/30 0:00:00'
create PROCEDURE [dbo].[receivableReportDateSet] -- Add the parameters for the stored procedure here @StartTime dateTime, @EndTime dateTime, @flag int = 0 output AS BEGIN SELECT busiPart.busiPartCode, busiPart.busiPartName, SUM(proSaleBill.totalPrice) as totalPrice, SUM(receiptBill.realReciAmount) as realReciAmount, AVG(busiPart.creditUsed) as creditUsed from busiPart left join proSaleBill on busiPart.busiPartName=proSaleBill.BusiName and proSaleBill.saleDate is not null and proSaleBill.saleDate<@EndTime and proSaleBill.saleDate>@StartTime left join receiptBill on busiPart.busiPartName=receiptBill.receDate and receiptBill.receDate is not null and receiptBill.receDate<@EndTime and receiptBill.receDate>@StartTime where (proSaleBill.saleDate<@EndTime and proSaleBill.saleDate>@StartTime) or (receiptBill.receDate<@EndTime and receiptBill.receDate>@StartTime) group by busiPart.busiPartName,busiPart.busiPartCode if (@@ROWCOUNT>0) Set @flag = 1 else Set @flag = 0 END
exec [receivableReportDateSet] '2012/5/27 0:00:00','2012/6/30 0:00:00'
TRY 修改第二个存储过程 CREATE PROCEDURE [dbo].[Receivablereportdateset] -- Add the parameters for the stored procedure here @StartTime DATETIME, @EndTime DATETIME, @flag INT = 0 output AS BEGIN SELECT busiPart.busiPartCode, busiPart.busiPartName, Sum(proSaleBill.totalPrice) AS totalPrice, Sum(receiptBill.realReciAmount) AS realReciAmount, Avg(busiPart.creditUsed) AS creditUsed FROM busiPart LEFT JOIN proSaleBill ON busiPart.busiPartName = proSaleBill.BusiName AND proSaleBill.saleDate IS NOT NULL AND proSa