amy_davis07 (3/16/2016)
Joining tables created by a LOOP!:hehe:
Since you are asking how to join the tables, I will just pretend not to have seen how you created them.
(But just for the record, loops are almost always a bad idea in SQL Server)
Any suggestions?
Post the data you have as a script that we can run, e.g. CREATE TABLE and INSERT statements that will recreate the same situation in our test database. Limit the data to just a few rows of sample data that covers all cases that need to be covered.
Post the *exact* expected result that you need based on the sample data provided, along with an explanation of the logic.
(And since you mention that you need output for every month in a 9-year period, I suggest that you post a simplified version for, let's say, a four-month period).