Location of a parenthesis (which should be correct) causes COQL where clause to fail

Location of a parenthesis (which should be correct) causes COQL where clause to fail


This where clause fails

queryMap.put({"select_query":"select In_Production, GS_Due, Stage from Production_Orders where (Stage != 'Shipped to Customer' and Stage != 'Delivered to Customer' and Stage != 'At Corporate') limit " + offset + ", 100"});


This one succeeds:

queryMap.put({"select_query":"select In_Production, GS_Due, Stage from Production_Orders where (Stage != 'Shipped to Customer' and Stage != 'Delivered to Customer') and Stage != 'At Corporate' limit " + offset + ", 100"});

The only difference is the location of the closing paren )

Why?