SELECT of two fields in the same table, prioritizing one field, but showing both

Asked

Viewed 13 times

0

Hello,

I have a bill release table to pay. There are fields like: data_de_lancamento, data_de_pagamento, data_pagamento_feito. What happens is that, in the query, I need for example: EX: I launched an account 05/06/2021, for payment in 05/07/2021, but paid only in 05/08/2021. In this example, the account would only appear in the report of the month 07, if it is open or if it was paid in the month 07, but as it was paid in the month 08, should appear only in the month 08.

I used the check by preference on the payment date, but I’m picking up in case the payment date made is registered, because it should be the preference, and after the payment date.

Thanks in advance.

  • Unclear , mainly without knowing the bank assuming Mysql I would try GREATEST(data_de_lancamento,data_de_pagamento,data_pagamento_feito) = .... https://www.w3schools.com/sql/func_mysql_greatest.asp

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.