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 |
just.net
Starting Member
24 Posts |
Posted - 2010-04-25 : 03:25:30
|
Hi,i have table like this:Time sum16/05/2010 16:36 $2,323.0016/06/2010 16:36 $4,232.0016/07/2010 16:36 $444.0016/08/2010 16:36 $32,444.0016/09/2010 16:36 $4,422.0016/05/2010 16:36 $2,323.0016/07/2010 16:36 $444.00i want to create a query that returns somthing like that:month sum5 $85,280.386 $888.007 $324,234.008 $34.009 $234.0010 $23,423.0011 $4,234.0012 $234.001 $4,234.002 $234.003 $234.004 $234.00it's result for the 12 months ahead from the current month.thanks alot. |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-25 : 03:34:40
|
what is the logic ? how do you get those numbers ? KH[spoiler]Time is always against us[/spoiler] |
|
|
just.net
Starting Member
24 Posts |
Posted - 2010-04-25 : 04:33:52
|
it's should be the SUM of the revenue in each month,these numbers are just random numbers.... |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-04-25 : 04:36:03
|
[code]select datepart(month, [Date]), sum(amount)from yourtablegroup by datepart(month, [Date])[/code] KH[spoiler]Time is always against us[/spoiler] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-25 : 05:03:37
|
if you've data for more than year thenselect datepart(year, [Date]),datepart(month, [Date]), sum(amount)from yourtablegroup by datepart(year, [Date]),datepart(month, [Date]) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
just.net
Starting Member
24 Posts |
Posted - 2010-04-25 : 06:26:59
|
Thank you all,so simple, but yet - so sophisticated. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-25 : 11:05:31
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|
|
|