There was two issues here. The first one, I resolved it by using the proper casing. So, just by trying your SQL as is, it works. But, the original problem remains. When being put together, among the original SQL with a AND NOT IN syntax, I still have this syntax problem around the word IN. The two SQLs work ok separetely. So, it's about a syntax when being put together. If you look in my other reply, you will obtain the entire syntax of it.