@@ -592,7 +592,7 @@ PRIMARY KEY (Workflow, StepNumber)
592
592
);
593
593
GO
594
594
595
- INSERT INTO ## ProcessLog VALUES
595
+ INSERT INTO #ProcessLog VALUES
596
596
(' Alpha' ,1 ,' Error' ),(' Alpha' ,2 ,' Complete' ),(' Alpha' ,3 ,' Running' ),
597
597
(' Bravo' ,1 ,' Complete' ),(' Bravo' ,2 ,' Complete' ),
598
598
(' Charlie' ,1 ,' Running' ),(' Charlie' ,2 ,' Running' ),
@@ -607,16 +607,15 @@ WITH cte_MinMax AS
607
607
SELECT Workflow,
608
608
MIN (RunStatus) AS MinStatus,
609
609
MAX (RunStatus) AS MaxStatus
610
- FROM ## ProcessLog
610
+ FROM #ProcessLog
611
611
GROUP BY Workflow
612
612
),
613
613
cte_Error AS
614
614
(
615
- SELECT
616
- Workflow,
615
+ SELECT Workflow,
617
616
MAX (CASE RunStatus WHEN ' Error' THEN RunStatus END ) AS ErrorState,
618
617
MAX (CASE RunStatus WHEN ' Running' THEN RunStatus END ) AS RunningState
619
- FROM ## ProcessLog
618
+ FROM #ProcessLog
620
619
WHERE RunStatus IN (' Error' ,' Running' )
621
620
GROUP BY Workflow
622
621
)
@@ -636,12 +635,12 @@ WITH cte_Distinct AS
636
635
SELECT DISTINCT
637
636
Workflow,
638
637
RunStatus
639
- FROM ## ProcessLog
638
+ FROM #ProcessLog
640
639
),
641
640
cte_StringAgg AS
642
641
(
643
642
SELECT Workflow,
644
- STRING_AGG (RunStatus,' , ' ) as RunStatus_Agg,
643
+ STRING_AGG (RunStatus,' , ' ) AS RunStatus_Agg,
645
644
COUNT (DISTINCT RunStatus) AS DistinctCount
646
645
FROM cte_Distinct
647
646
GROUP BY Workflow
0 commit comments