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 |
bobred
Starting Member
14 Posts |
Posted - 2014-12-01 : 05:10:38
|
HiWe have an inventory of devices we service and wish to show the total numbers of active devices per month going 12 months back.How would I go about this?James |
|
sunder.bugatha
Yak Posting Veteran
66 Posts |
Posted - 2014-12-01 : 09:31:12
|
Can you share sample data?Hema Sunder |
|
|
sz1
Aged Yak Warrior
555 Posts |
Posted - 2014-12-01 : 09:44:48
|
Something like this:Declare @MonthPast12 Date = Dateadd(MONTH, -12, InventoryDate)Select DeviceName, DateName(Month, [InventoryDate]) 'MonthName', Count([DeviceName]) 'DeviceTotal' From Inventory Where [InventoryDate] <= [@MonthPast12] Group By [DeviceName], [InventoryDate] GoWe are the creators of our own reality! |
|
|
|
|
|