取到对应的年,月
select * from B where LEFT(yf, 4)='${nd}' AND month(yf) <= '${yf}'
参考,改成你的表,和时间字段
select * from (select max(datadate) as datadate from monitor_data where datadate>= ‘2020-01-01’ and datadate<=‘2020-09-13’ GROUP BY to_char(datadate, ‘yyyy-mm’) ) t ORDER BY t.datadate desc