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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Revenue by month

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,
OrderValue

The 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, then

Select convert(varchar,datepart(mm,EndDate)) + '-' + convert(varchar,datepart(yy,Enddate)),sum(OrderValue)
from TableName
Group By convert(varchar,datepart(mm,EndDate)) + '-' + convert(varchar,datepart(yy,Enddate))


Prakash.P
The secret to creativity is knowing how to hide your sources!
Go to Top of Page

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 : 2000
month 3 : 0

etc.

Go to Top of Page

pravin14u
Posting Yak Master

246 Posts

Posted - 2008-03-31 : 05:31:23
You can try some thing like this,

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99945

But not sure if this is the best way to do


Prakash.P
The secret to creativity is knowing how to hide your sources!
Go to Top of Page

lwarunek
Starting Member

22 Posts

Posted - 2008-03-31 : 05:41:06
cheers!
Go to Top of Page
   

- Advertisement -