USE [Laundry]
GO
/****** Object: StoredProcedure [dbo].[lbReport_Select_t_biz_payment_info] Script Date: 11/17/2012 14:03:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[lbReport_Select_t_biz_payment_info]
(
@year nvarchar(50)
)
AS
--程序时间--
SELECT @year AS [Year]
--程序主体--
SELECT (CASE monthcolumn WHEN 1 THEN 'Jan' WHEN 2 THEN 'Feb' WHEN 3 THEN 'March' WHEN 4 THEN 'April' WHEN 5 THEN 'May' WHEN 6 THEN 'June' WHEN 7 THEN 'July' WHEN 8 THEN 'Aug' WHEN 9 THEN 'Sept' WHEN 10 THEN 'Oct' WHEN 11 THEN 'Nov' WHEN 12 THEN 'Dec' ELSE 'Error' END) AS [Month] ,SUM(CASE WHEN DATEPART(m,Payment.createdate)=monthcolumn AND Invoice.distributetype = '01' THEN payamount ELSE 0 END) AS Pickup,SUM(CASE WHEN DATEPART(m,Payment.createdate)=monthcolumn AND Invoice.distributetype != '01' THEN payamount ELSE 0 END) AS Delivery FROM t_biz_payment_info AS Payment INNER JOIN t_biz_invoice_info AS Invoice ON Payment.invoiceid = Invoice.id,MonthList WHERE DATEPART(YYYY,Payment.createdate)=@year GROUP BY monthcolumn ORDER BY [Month]