I have a complex join, which I simplified below. There is a case statement in my view which basically produces what we need as the result of the complex joins. The issue is that