What is this query supposed to be doing? What are the driving inputs and the required outputs.
You still need to provide the DDL and sample data in a readily consumable format, one that simply requires use to do a cut and paste into an empty Sandbox database and work to setup a working environment to help you.