So I'm building a query for a graph in .net. My issue is, I have no clue on how to add up the month to the next month. So here is my query below and what I am getting from it.
I would like that for example, April would be = to April + Jan, Fev, March ... and so on so June would be = to June + Jan, Feb, March, Apr, May ....
SELECT COUNT(*) As 'Deployed',
DATENAME(YEAR, LastModified) As 'Year',
DATEPART(Month, LastModified),
DATENAME(Month, LastModified) As 'Month'
FROM [InventoryDatabase].[dbo].[Hardware_RefreshList]
WHERE Asset_Type = 'Laptop' AND Status = 'Completed' AND Department != 'SNBc'
AND DATENAME(YEAR, LastModified) = '2017'
GROUP BY DATEPART(Month, LastModified), DATENAME(YEAR, LastModified),
Month(LastModified), DATENAME(Month, LastModified),
DATEADD(MONTH, DATEDIFF(MONTH, 0, LastModified), 0)
ORDER BY DATEPART(Month, LastModified)
Result from the query
2 2017 3 March 6 2017 4 April 8 2017 6 June 6 2017 7 July 9 2017 9 September 29 2017 10 October 10 2017 11 November 54 2017 12 December