• First, the png file really doesn't cut it. You need to post the DDL (CREATE TABLE statements) for the tables involved, sample data for the tables as INSERT INTO statements to populate the tables with sample (NOT production) data, and then the expected results based on the sample data you provide.

    Also, be sure to test all your scripts in an empty database to be sure the run without errors. Also make sure you are consistent in the naming of columns including case sensitivity (even in a case insensitive environment).