0 votes
in Rock by MarissaEubanks (4.0k points)
edited

Anyone have any suggestions on the best way to pull all active workflows that are > a certain # of days old?? Other than workflow by workflow...and without crashing Rock, preferably.

by MarissaEubanks (4.0k points)
SELECT * FROM WorkflowWHERECompletedDateTime IS NULLand CreatedDateTime < DATEADD( DAY, 60, GETDATE() )

1 Answer

+1 vote
by DavidTurner (14.9k points)
edited
 
Best answer

This query will show the number of active workflows for each workflow type.

SELECT T.[Id], T.[Name], COUNT(*) AS [HowMany]
FROM [Workflow] W
INNER JOIN [WorkflowType] T ON T.[Id] = W.[WorkflowTypeId]
WHERE W.[CompletedDateTime] IS NULL
--AND W.[ActivatedDateTime] > DATEADD(d,-7,GETDATE())
GROUP BY T.[Id], T.[Name]
ORDER BY [HowMany] DESC

(The line's that commented out can be used to only show workflows that have been activated within the last 7 days)

Welcome! Here you can ask questions and receive answers (hopefully) from other members of our team.
...