When attempting to execute the code, there appear to be some syntax errors related to missing aliases for subqueries.
Msg 102, Level 15, State 1, Line 459
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 465
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 477
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 483
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 494
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 500
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 511
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 517
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 528
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 534
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 545
Incorrect syntax near ')'.
Msg 102, Level 15, State 1, Line 551
Incorrect syntax near ')'.
Adding an alias (e.g. as subq) at each of these points in the code allows the query to run.
When attempting to execute the code, there appear to be some syntax errors related to missing aliases for subqueries.
Adding an alias (e.g.
as subq
) at each of these points in the code allows the query to run.