Where a question concerns query performance, how should the query be included in the question if it is very long (tens or even hundred of lines)?
On SO, code posted in a question should be whittled down to just the relevant lines. However, with an SQL query, subdividing it will change the behaviour and performance.