By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE taxes (created_at date, tax int);
INSERT INTO taxes VALUES
('2020-01-05', 300),
('2020-06-10', 350),
('2020-09-15', 400),
('2020-09-28', 320);
WITH RECURSIVE dates (created_at) AS (
SELECT '2020-02-01' as created_at
UNION ALL
SELECT DATE_ADD(created_at, INTERVAL 1 MONTH)
FROM dates WHERE created_at <= '2020-10-30'
), result AS (
SELECT created_at, tax FROM taxes
UNION
SELECT created_at, (
SELECT tax FROM taxes t
WHERE t.created_at <= d.created_at
ORDER BY t.created_at DESC LIMIT 1
) AS tax
FROM dates d
)
SELECT * FROM result
WHERE created_at BETWEEN '2020-02-01' AND '2020-10-30'
ORDER BY 1
created_at | tax |
---|---|
2020-02-01 | 300 |
2020-03-01 | 300 |
2020-04-01 | 300 |
2020-05-01 | 300 |
2020-06-01 | 300 |
2020-06-10 | 350 |
2020-07-01 | 350 |
2020-08-01 | 350 |
2020-09-01 | 350 |
2020-09-15 | 400 |
2020-09-28 | 320 |
2020-10-01 | 320 |