Source
A query using a correlated column inside a window function fails with internal error 300010:391167117
SOLUTION: To resolve this issue, avoid using correlated columns inside a window function. This can be achieved by moving the window aggregation function to the outer query.
Selecting particular columns from a table using column order
ISSUE: The most common way to select a particular column from a table is doing it by name, but you can also do it using the column order. It can quite a useful when your query is heavily nested and you don't want to use aliases to avoid…