No offense....but this is crazy? It is so simple in oracle and sql server.
The above example still doesnt really work. You would still have modify the statement more and add union all.
Then copy all the output window to another sql asst session.
THere has to be simplier code