With the following query I can use the LAG() function to repeat the last non null value of c column:
SELECT coalesce(open_time, extract(EPOCH from date_trunc('minute', datetime)) * 1000) open_time,
coalesce(o, LAG(c) over w) o,
coalesce(h, LAG(c) over w) h,
coalesce(l, LAG(c) over w) l,
coalesce(c, LAG(c) over w) c,
coalesce(v, 0) v,
coalesce(close_time, extract(EPOCH from date_trunc('minute', datetime)) * 1000 + ((60000 * 1) - 1)) close_time
from temporary_timeframe
window w as (order by datetime);
Getting the following result:
But I need to repeat the value of the c column while the current column value is null. I see that if PostgreSQL supports IGNORE NULLS attribute on window functions this would be solved. How to solve this without IGNORE NULLS?
