Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/*
This query will show you the count of records per Hardware Inventory class in your HinvChangeLog table for a period between
21 days ago, and 28 days ago
*/
SELECT map.DisplayName
, map.InvClassName AS 'Inventory View'
, COUNT(HINV.RecordID)
FROM HinvChangeLog hinv
LEFT JOIN v_GroupMap map ON map.GroupID = hinv.GroupKey
WHERE hinv.TimeKey > DATEADD(day, -28, GETDATE()) AND hinv.TimeKey < DATEADD(day, -21, GETDATE())
GROUP BY map.DisplayName
, map.InvClassName
ORDER BY 3 DESC
/*
This query will show you the count of records per Hardware Inventory class in your HinvChangeLog table for the last week
*/
SELECT map.DisplayName
, map.InvClassName AS 'Inventory View'
, COUNT(HINV.RecordID)
FROM HinvChangeLog hinv
LEFT JOIN v_GroupMap map ON map.GroupID = hinv.GroupKey
WHERE hinv.TimeKey > DATEADD(day, -7, GETDATE())
GROUP BY map.DisplayName
, map.InvClassName
ORDER BY 3 DESC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.