所以我正在为.net 中的图表构建一个查询。我的问题是,我不知道如何将月份加到下个月。所以这是我下面的查询以及我从中得到的信息。
例如,我希望 4 月 = 到 4 月 + 1 月、Fev、3 月……等等,所以 6 月 = 到 6 月 + 1 月、2 月、3 月、4 月、5 月……
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