Skip to content

Commit dd36d0b

Browse files
Update Advanced SQL Puzzles Solutions.sql
1 parent 5f1dae8 commit dd36d0b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

Advanced SQL Puzzles/Advanced SQL Puzzles Solutions.sql

+6-7
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ PRIMARY KEY (Workflow, StepNumber)
592592
);
593593
GO
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
607607
SELECT Workflow,
608608
MIN(RunStatus) AS MinStatus,
609609
MAX(RunStatus) AS MaxStatus
610-
FROM ##ProcessLog
610+
FROM #ProcessLog
611611
GROUP BY Workflow
612612
),
613613
cte_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
620619
WHERE RunStatus IN ('Error','Running')
621620
GROUP BY Workflow
622621
)
@@ -636,12 +635,12 @@ WITH cte_Distinct AS
636635
SELECT DISTINCT
637636
Workflow,
638637
RunStatus
639-
FROM ##ProcessLog
638+
FROM #ProcessLog
640639
),
641640
cte_StringAgg AS
642641
(
643642
SELECT Workflow,
644-
STRING_AGG(RunStatus,', ') as RunStatus_Agg,
643+
STRING_AGG(RunStatus,', ') AS RunStatus_Agg,
645644
COUNT(DISTINCT RunStatus) AS DistinctCount
646645
FROM cte_Distinct
647646
GROUP BY Workflow

0 commit comments

Comments
 (0)