MySQL Forums
Forum List  »  Spanish

Re: Restas condicionadas en MYSQL para vba
Posted by: victor flores
Date: September 21, 2021 03:36PM

Muchas gracias Peter, por favor corrígeme si estoy equivocado LAG Y LEAD se utilizan para para utilizar la fila anterior y posterior. Para poder aplicar la resta tendría que anidar dos lag? Si hubiera un dato intermedio y no fueran consecutivos eso no me marcaría un error?

Actualmente estoy intentado algo así pero me marca error.

select id, IMPORTE, (IMPORTE where CODIGO = 200 AND CONCEPTO = 'P') - (IMPORTE where CODIGO = 201 AND CONCEPTO = 'P') AS Pago FROM Nomina;

o

select IMPORTE FROM Nomina where SELECT * FROM Nomina where CODIGO = 200 AND CONCEPTO = 'P' - IMPORTE FROM Nomina where CODIGO = 202 AND CONCEPTO = 'P' AS Pago FROM nomina;

Options: ReplyQuote


Subject
Views
Written By
Posted
359
September 21, 2021 02:12PM
Re: Restas condicionadas en MYSQL para vba
178
September 21, 2021 03:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.