Any luck with the query? I read the page of the link you sent. Not sure how to implement this in my project.
SUCKS being a noooob at SQL. But I have leaned a ton from this site thus far.
This is what I came up with:
@CustomerID varchar(15),
@Year varchar(15)
AS
BEGIN
select
sum(case when invoice_date between '1/1/'+@Year and '1/31/'+@Year then total_amount else 0 end) as 'Jan',
sum(case when invoice_date between '2/1/'+@Year and '2/28/'+@Year then total_amount else 0 end) as 'Feb',
sum(case when invoice_date between '3/1/'+@Year and '3/31/'+@Year then total_amount else 0 end) as 'Mar',
sum(case when invoice_date between '4/1/'+@Year and '4/30/'+@Year then total_amount else 0 end) as 'Apr',
sum(case when invoice_date between '5/1/'+@Year and '5/31/'+@Year then total_amount else 0 end) as 'May',
sum(case when invoice_date between '6/1/'+@Year and '6/30/'+@Year then total_amount else 0 end) as 'Jun',
sum(case when invoice_date between '7/1/'+@Year and '7/31/'+@Year then total_amount else 0 end) as 'Jul',
sum(case when invoice_date between '8/1/'+@Year and '8/31/'+@Year then total_amount else 0 end) as 'Aug',
sum(case when invoice_date between '9/1/'+@Year and '9/30/'+@Year then total_amount else 0 end) as 'Sep',
sum(case when invoice_date between '10/1/'+@Year and '10/31/'+@Year then total_amount else 0 end) as 'Oct',
sum(case when invoice_date between '11/1/'+@Year and '11/30/'+@Year then total_amount else 0 end) as 'Nov',
sum(case when invoice_date between '12/1/'+@Year and '12/31/'+@Year then total_amount else 0 end) as 'Dec',
sum(case when year(invoice_date) = 2009 then total_amount else 0 end) as 'Total'
from receivable
WHERE (RECEIVABLE.CUSTOMER_ID=@CustomerID)
END
This works fine if I send a year and a customerid. But the requirement is for a date range to be sent like I had in my other query.
like feb 3 2007 - dec 3 2009
Any help would be awesome.. thanks for the link which helped me get to the above query... Crawl-Walk-Run