I have my main query which I have been slowy adding to, to get the desired results. I added in most recent piece and I get the follwoing error and cannot seem to get past it.
Msg 512, Level 16, State 1, Line 1
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
Warning: Null value is eliminated by an aggregate or other SET operation.
See text file for all code.