How to get Running Total based on start date and end date in MYSQL
问题 I have sample data like the below . Start_Dt End_Dt Dur_of_months amount 2020-01-01 2020-04-01 4 800 where I have Start date and End Date along Duration of months. By dividing amount (800) by 4 = 200. I want to get running total minus (200) for each month . output : mon_dt amount Jan 2020 800 Feb 2020 600 Mar 2020 400 Apr 2020 200 I have some code to increment the months between start date and End date SELECT ID, DATE_FORMAT(Startdate + INTERVAL n.n MONTH, '%M %Y') AS Dates FROM dates JOIN (