fix errors in sql