The select statements are quite large so in a simplified presentation my issue is:
I am troubleshooting using a specific test case where only one result is returned, to test #1 alone and within a UNION’d chain of SELECT statements.
I have a SELECT statement (#1) that works (ie-returns the one test case as expected).
I have a different SELECT UNION SELECT UNION SELECT UNION SELECT statement (#2) that works for the data it is intended to return, but should return nothing with the test case.
When I add #1 to the end of #2 by adding a fifth SELECT , and look for the test case, I get no results returned.
Is there something I am missing here about how UNIONS join result sets together? I know I’m not looking at the difference between a UNION and UNION ALL, as only one result should be found.
Any ideas?
My select statement in #2 was not identical to #1.