Starting with just a little piece of the query, as this is probably all you should need to show the stats/count for a single node...
SELECT TOP 1 SUM(((LEN(XmlResults) - LEN(REPLACE(XmlResults, 'access profile BB12', '')))/LEN('access profile BB12')-1))OVER() as "BB12" FROM SWNPMDB.dbo.NCM_PolicyCacheResults WHERE ([IsViolation]=1) AND ([RuleName]='access profile BB12') GROUP BY XmlResults
On the first line, you need to replace 'access profile BB12' with the string you are looking for. In my case, I had to add the ")-1)" because my interfaces list this string twice for each interface. Adding the -1 makes it only read the 1 instance for each interface.
SELECT TOP 1 SUM(((LEN(XmlResults) - LEN(REPLACE(XmlResults, 'access profile BB12', '')))/LEN('access profile BB12')-1))OVER() as "BB12"
On the second line, you need to change it to match your database name. Just change the "SWNPMDB" part to the name of your database.
FROM SWNPMDB.dbo.NCM_PolicyCacheResults
On the third line, you need to change the value for the RuleName to match the name of your rule. The name of the rule I created/used was "access profile BB12". Yours might look something similar to ([RuleName]='StormControl').
WHERE ([IsViolation]=1) AND ([RuleName]='access profile BB12')
Finally, you will need to go into the Orion Report Writer application, and put the SQL query into a report, and then save it.
Afterwards, you need to add a report resource to a page, and choose the newly created report to fill that resource.
The query listed below, should create a list of all devices/nodes that have at least 1, or more, violations, and show a count of how many violations each device/node has.
You will need to change my database name to match yours. So, replace all instances of "SWNPMDB" with the name of your database.
The only other thing you will need to change is the rule name. On line 7, replace 'access profile BASIC', with the name of the rule you are using. Yours may look something like this: (PCR.RuleName = 'StormControl')
SELECT CAST(PCR.XmlResults AS XML).query('count(//L)') AS NumProvisioned, ND.NodeID, ND.Caption, ND.IP_Address, PCR.ConfigID, PCR.NodeID FROM SWNPMDB.dbo.NCM_PolicyCacheResults PCR JOIN SWNPMDB.dbo.NCM_NodeProperties NP ON (NP.NodeID = PCR.NodeID) JOIN SWNPMDB.dbo.NodesData ND ON (ND.NodeID = NP.CoreNodeID) WHERE (PCR.RuleName = 'access profile BASIC') AND (PCR.IsViolation = 1) --GROUP BY --N.NodeID, PCR.RuleName, N.Caption, N.IP_Address, PCR.IsViolation, PCR.XmlResults ORDER BY ND.Caption ASC
You will need to save this as a custom SQL report in Orion Report Writer, similar to the previous query/report, listed above.
I know my explanation is most likely not the best, however, I am just now learning all of this SQL stuff too, so I do not have much knowledge to pass on for that... yet, anyway.
I hope it helps. Let us know if you still need help.
Thank you,
-Will