I have created a UnDP that returns 10 rows of "status" values on each query. These values are 1 thru 7. What I am trying to do is get a count of rows that have a status value of 4. (4 = "installed and operational".
I have created the following stored procedure in the database --
USE [SolarWindsOrion]
GO
/****** Object: StoredProcedure [dbo].[GetLastStatusCountForPoller] Script Date: 05/05/2015 14:54:01 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROC [dbo].[GetLastStatusCountForPoller]
@PollerName NVARCHAR(255) ,
@Status NVARCHAR(1000)
AS
SELECT TOP 1 cpsd.DateTime [LastPollDate],@PollerName as Poller,@Status as [Status], COUNT(*) AS [Count]
FROM dbo.CustomPollers cp
INNER JOIN dbo.CustomPollerAssignment cpa ON cp.CustomPollerID = cpa.CustomPollerID
INNER JOIN dbo.CustomPollerStatistics_Detail cpsd ON cpa.CustomPollerAssignmentID = cpsd.CustomPollerAssignmentID
WHERE cp.UniqueName = @PollerName
AND cpsd.Status = @Status
GROUP BY
cp.CustomPollerID,cpa.CustomPollerAssignmentID , cpsd.DateTime
ORDER BY cpsd.DateTime DESC
By running a query with --
EXEC GetLastStatusCountForPoller 'upsDiagPMStatus',4
GO
I am successfully getting a count of 3. My problem is in figuring out how to use this in a transform formula.
Can anyone provide some guidance in implementing either the entire procedure, or just the EXEC in a transform formula ?