smw147 (9/15/2014)
Thanks all. The CTE and rbednarek's solution both worked.
The question now is, what did the changes do to performance and resource usage? The reason I ask is that a common technique for fixing performance and resource usage problems associated with many "all in one queries" is to split up the query and put the essential "driver rows" into a temp table and include that in the join.
To be sure, "Set Based" coding is the way to go but it doesn't mean "All in one query".
--Jeff Moden
Change is inevitable... Change for the better is not.