Re: Calender Month, Trended Report
- From: JPD <nospam@xxxxxxxxxx>
- Date: Tue, 10 Jul 2007 15:33:14 +0100
Hi Wez,
This should do it:
select datepart(mm, SaleDate), sum(SaleValue)
from test.dbo.sales
group by datepart(mm, SaleDate)
Jonathan
Wez wrote:
Hi,.
I have one table with two columns, namely "SaleValue" & "SaleDate".
A snap shot of the table is as follows:
SaleValue SaleDate
--------------- ------------
500.23 2007-06-02
601.45 2007-06-01
300.21 2007-05-30
761.00 2007-05-19
411.54 2007-05-04
398.21 2007-04-17
831.22 2007-03-21
973.02 2007-03-11
432.33 2007-03-01
143.54 2007-02-18
I would like a query that will return a 6 month trended sales (calendar month), starting with the previous month.
So for the above data, my result set would be as follows:
May-07 Apr-07 Mar-07 Feb-07 Jan-07 Dec-06 1472.75 398.21 2236.57 143.54 0.00 0.00
Many Thanks,
Wez
- Next by Date: Re: MS Query in EXCEL will not accept additional text
- Next by thread: Re: MS Query in EXCEL will not accept additional text
- Index(es):