What is causing the SQL syntax error in my WITH statement query