In the table in above link, the balance_aftermonths
holds the remaining balance after each month. For current year, I want to check the remaining balance after each month in current year , which I calculate using :
where MONTH(monthlydates) = MONTH(curdate())
However, for the older dates (for example 2019 in example), the total remaining balance should not be current month but the last month in the contract, something like this:
WHERE YEAR(monthlydates) = YEAR(end_date) AND MONTH(monthlydates) = MONTH(end_date)
QUESTION: My question is that, how these two can be accommodated in a single query?
Aucun commentaire:
Enregistrer un commentaire