Solutionunvalidated

Split the script into two separately executed parts: first run only the DROP/CREATE TEMP TABLE statements, then execute the SELECT query in a separate execution so the temp tables exist in the same session.

c737f755-934a-4219-8217-c2583d78e9cf

Split the script into two separately executed parts: first run only the DROP/CREATE TEMP TABLE statements, then execute the SELECT query in a separate execution so the temp tables exist in the same session.