日期:2014-05-17 浏览次数:20801 次
--参数说明: @date 是传入的时间 如果对某年的一个月份进行统计 则该月份的第一天日期一‘2013-03-01’这样形式传入即可
-- @costumeID 是客户的ID 对相应的客户进行月报表的详细统计 如果参数为null 则对这个月份的所有客户进行月报表的详细统计
CREATE proc p_Report_Month_Day
@date nvarchar(10),
@pruductID bigint=null,
@addressID bigint=null,
@providerID bigint =null,
@costumeID bigint=null ,
@employeeID bigint=null
as
set nocount on
SELECT ID, DATEADD(DAY,ID-1,@date) AS 日期,ISNULL(销售总价,0) AS 总价
FROM
(
SELECT ID=ROW_NUMBER() OVER (ORDER BY GETDATE()) FROM sysobjects
) A
LEFT JOIN
(
SELECT saleDate,sum(total) 销售总价
FROM T_sale
where
( @pruductID is null or productID=@pruductID)--品名
AND ( @addressID is null or addressID=@addressID)--产地
AND ( @providerID is null or providerID=@providerID)--供应商
AND ( @costumeID is null or costumeID=@costumeID)--客户
AND ( @employeeID is null or employeeID=@employeeID)--员工
GROUP BY saleDate
) B
ON CONVERT(VARCHAR(10),DATEADD(DAY,ID-1,@date),120)=saledate
WHERE DATEDIFF(MONTH,@date,DATEADD(DAY,ID-1,@date))=0
exec p_Report_Month_Day '2013-03-01',null,null,null,1,null
T_saleTableAdapter sale = new T_saleTableAdapter();
JXCManagement.DAL.DataSetSale.T_saleDataTable data=null;
data= sale.Report_Month_Day("2013-03-01", n