Fixed errors in sql.