Diferent result between query and application (MySQL)
Make sure both approaches are looking the same DATABASE.

Further debugging:


Turn on the general log.
Run the query both ways.
Turn off the general log.
Compare the two queries; there must be something different.
Figure out what is changing what.


Meanwhile, these indexes may help performance:

creditos_ren:  INDEX(id_credito, canceladom fecha_vto, id)
creditos:      INDEX(gestion_local, enumerador)


What table is id_Cliente in?