SELECT
@lastDay := last_day( date_add(@lastDay,interval 1 month ) ) lastDays
from
(SELECT @lastDay := date_add(curdate(),interval -6 month) from application limit 6) a;
SELECT
date_format(@lastDay := last_day( date_add(@lastDay,interval 1 month ) ) ,'%Y-%m' ) lastDays
from
(SELECT @lastDay := date_add(curdate(),interval -6 month) from application limit 6) a;
输出: