Originally Posted by
hapm
Why do you even use having here? You don't need the count function, but the Len() function to get the length of the names. As you don't need the count, you don't have any aggregates at all and don't need a having clause. All your conditions go into the where clause. For the mixing of AND and OR: its like with multiplication and addition in math. Multiplication takes precedence over addition, so 4+2*3 = 10. In boolean algebra AND normally takes precedence over OR: True OR False AND True = False. If you want it the other way round, you will need to add brackets as June7 said.