@@ -592,7 +592,7 @@ PRIMARY KEY (Workflow, StepNumber)
592592);
593593GO
594594
595- INSERT INTO ## ProcessLog VALUES
595+ INSERT INTO #ProcessLog VALUES
596596(' Alpha' ,1 ,' Error' ),(' Alpha' ,2 ,' Complete' ),(' Alpha' ,3 ,' Running' ),
597597(' Bravo' ,1 ,' Complete' ),(' Bravo' ,2 ,' Complete' ),
598598(' Charlie' ,1 ,' Running' ),(' Charlie' ,2 ,' Running' ),
@@ -607,16 +607,15 @@ WITH cte_MinMax AS
607607SELECT Workflow,
608608 MIN (RunStatus) AS MinStatus,
609609 MAX (RunStatus) AS MaxStatus
610- FROM ## ProcessLog
610+ FROM #ProcessLog
611611GROUP BY Workflow
612612),
613613cte_Error AS
614614(
615- SELECT
616- Workflow,
615+ SELECT Workflow,
617616 MAX (CASE RunStatus WHEN ' Error' THEN RunStatus END ) AS ErrorState,
618617 MAX (CASE RunStatus WHEN ' Running' THEN RunStatus END ) AS RunningState
619- FROM ## ProcessLog
618+ FROM #ProcessLog
620619WHERE RunStatus IN (' Error' ,' Running' )
621620GROUP BY Workflow
622621)
@@ -636,12 +635,12 @@ WITH cte_Distinct AS
636635SELECT DISTINCT
637636 Workflow,
638637 RunStatus
639- FROM ## ProcessLog
638+ FROM #ProcessLog
640639),
641640cte_StringAgg AS
642641(
643642SELECT Workflow,
644- STRING_AGG (RunStatus,' , ' ) as RunStatus_Agg,
643+ STRING_AGG (RunStatus,' , ' ) AS RunStatus_Agg,
645644 COUNT (DISTINCT RunStatus) AS DistinctCount
646645FROM cte_Distinct
647646GROUP BY Workflow
0 commit comments