SQLize Online / PHPize Online

A A A
Share   Donate   Blog   Popular
Copy Format Clear
CREATE TABLE d ( date datetime, val int ); insert into d values ('2022-04-01', 10), ('2022-04-15', 15); select * from d; WITH [range] AS ( SELECT 0 as v UNION ALL SELECT v + 1 FROM range t WHERE t.v < 29 ) SELECT DISTINCT dateadd(day, v, '2022-04-01') Date, FIRST_VALUE(D.val) OVER (PARTITION BY v ORDER BY D.Date DESC) Val FROM [range] LEFT JOIN D ON D.Date <= dateadd(day, v, '2022-04-01') ORDER BY Date, Val
Stuck with a problem? Need help? Ask professionals on our Telegram channel!
Join the channel
Your quersion is posted.
Join our Telegram channel and get answers.
Send
Copy