I have written a sql query to get Total Active Customer as
SELECT
Cast((Datepart(year,[p].Transdate)) as varchar(50)) + '-' +
Cast((Datepart(Month,[p].Transdate)) as varchar(50)) AS [Month/Year] ,
Count(Distinct([c].CustomerID)) as [Active Customers]
FROM
CustomerPoints as [p]
INNER JOIN
Customers AS [c] ON [c].[CustomerID] = [p].[CustomerID]
WHERE
[p].Transdate BETWEEN '2013-01-20' AND '2015-03-05'
AND [c].DistributorID = '1'
AND [p].[TransType] = 'D'
AND [p].[Litres] > '0'
GROUP BY
Cast((Datepart(Year,[p].Transdate)) AS varchar(50)) + '-' +
Cast((Datepart(Month,[p].Transdate)) AS varchar(50))
ORDER BY
Cast((Datepart(Year,[p].Transdate)) AS varchar(50)) + '-' +
Cast((Datepart(Month,[p].Transdate)) AS varchar(50)) ASC
and I got the output as
Month/year ActiveCustomer
----------------------------------
2013-1 1
2014-3 1
2015-2 1
but I want output as summation active members of previous month + active members of current month
Month/year Active Customer
-------------------------------
2013-1 1
2014-3 2
2015-2 3