Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
lwarunek
Starting Member
22 Posts |
Posted - 2008-03-31 : 04:29:05
|
Hi everybody!Is there any way that I could achieve displaying the revenue grouped by a month?I've got the following fields in order table:DateClosed,StartDate,EndDate,OrderValueThe fiscal year starts in march and ends in feb.I know how to calculate the year's revenue but I have got difficulties in spreading it over the months.Any thoughts?Thanks in advance. |
|
pravin14u
Posting Yak Master
246 Posts |
Posted - 2008-03-31 : 04:43:28
|
Which date do you consider for grouping? if it is EndDate, thenSelect convert(varchar,datepart(mm,EndDate)) + '-' + convert(varchar,datepart(yy,Enddate)),sum(OrderValue)from TableNameGroup By convert(varchar,datepart(mm,EndDate)) + '-' + convert(varchar,datepart(yy,Enddate))Prakash.PThe secret to creativity is knowing how to hide your sources! |
|
|
lwarunek
Starting Member
22 Posts |
Posted - 2008-03-31 : 04:48:04
|
Thanks. But this solution will only display the months that are present for the chosen date.I would like to have list of all months from 1-12 and for each month calculated value. So, if there is no value for month 1 there would be Null or zero.e.g.month 1 : 0 (NULL)month 2 : 2000month 3 : 0etc. |
|
|
pravin14u
Posting Yak Master
246 Posts |
|
lwarunek
Starting Member
22 Posts |
Posted - 2008-03-31 : 05:41:06
|
cheers! |
|
|
|
|
|
|
|