I think there is a typo in the answer as it describes query number 2 in the answer but mentions a WHERE clause which only exists in Query number 3. It mentions Query number 1 and mentions it uses a CTE, which is used in Query number 2.
The correct answer is query 2; the answer just incorrectly mentions query 2 as not running instead of query 3 as not running and that query 1 is the answer when query 2 is the answer.
The above is all just my opinion on what you should do.
As with all advice you find on a random internet forum - you shouldn't blindly follow it. Always test on a test server to see if there is negative side effects before making changes to live!
I recommend you NEVER run "random code" you found online on any system you care about UNLESS you understand and can verify the code OR you don't care if the code trashes your system.