Currently I am running this query to get a sum for each day.
select Activity,
act_a = sum(case tintactivitytype when 3 then 1 else 0 end),
act_b = sum(case tintactivitytype when 4 then 1 else 0 end)
from dbo.tblpostpaid
group by activity
order by activity
the column activity is a 'datetime'
part of my output is as follows.
activity act_a act_b
2007-03-05 23:31:27.000 0 1
2007-03-23 17:38:49.000 0 0
2007-03-22 02:36:00.000 0 1
2007-03-17 11:48:20.000 0 0
2007-03-12 15:49:11.000 0 0
2007-03-25 09:56:54.000 0 0
2007-04-01 13:39:47.000 0 1
...
...
...
I want to get something like this..
activity act_a act_b
2007-03 8 9
2007-02 6 5
2007-01 12 10
2006-12 11 8
...
* the values in act_a and act_b are just sample values ..
basically I want to sum the act_a and act_b values and report it over a month to month basis?
are there any special function in sqlserver that can help me do this?
select Activity,
act_a = sum(case tintactivitytype when 3 then 1 else 0 end),
act_b = sum(case tintactivitytype when 4 then 1 else 0 end)
from dbo.tblpostpaid
group by activity
order by activity
the column activity is a 'datetime'
part of my output is as follows.
activity act_a act_b
2007-03-05 23:31:27.000 0 1
2007-03-23 17:38:49.000 0 0
2007-03-22 02:36:00.000 0 1
2007-03-17 11:48:20.000 0 0
2007-03-12 15:49:11.000 0 0
2007-03-25 09:56:54.000 0 0
2007-04-01 13:39:47.000 0 1
...
...
...
I want to get something like this..
activity act_a act_b
2007-03 8 9
2007-02 6 5
2007-01 12 10
2006-12 11 8
...
* the values in act_a and act_b are just sample values ..
basically I want to sum the act_a and act_b values and report it over a month to month basis?
are there any special function in sqlserver that can help me do this?