WITH
balance(userid, date, balance_amount) AS (
VALUES ('1112879', DATE '2022-08-05',700),
('1112879', DATE '2022-08-15',1500),
('1112879', DATE '2022-08-18',10100),
('1112879', DATE '2022-08-22',1700),
('1112879', DATE '2022-09-01',4200)
)
select
day::date,
(select balance_amount from balance as t where t.userid = balance.userid and (day::date - t.date::date)>=0 ORDER BY abs(day::date - t.date::date) asc limit 1) as amount,
balance.userid
from
generate_series('2022-08-01'::date, now()::date, '1 day'::interval) as day
cross join (select userid from balance group by userid) as balance
ORDER BY day;