Uncommenting either of the commented lines returns the result I am after (i.e. 1), but running the code as is returns a different result for MbrshpNbr = 20691660 (i.e. 28). The fact different results are returned leads me to believe I should be using derived tables such as pointed out by Dieter here, but was wondering if this is necessary?