I'm looking to take values from an event log that occur on a sporadic basis and extend these values on all dates between events. For example:
A full series may look like...
2013-01-01
2013-01-02
2013-01-03
2013-01-04
2013-01-05
But the event log looks like...
2013-01-01 | value_1
2013-01-04 | value_2
The desired end result is as follows...
2013-01-01 | value 1
2013-01-02 | value 1
2013-01-03 | value 1
2013-01-04 | value 2
2013-01-05 | value 2
As solution I'm trying to generate a full series of dates, left join the selective event log dates onto that full series, and then fill in the NULL values with the desired values, but I'm running into an issue where my left join produces inner join results.
select
days.date,
e.value
from
--Generate table for dates
(select
row_number() over (),
generate_series::date as date
from
generate_series('2009-01-01',current_date + interval '100 days',interval '1 day')) days
--Combine actual change log
left join
(select
value,
event_date
from event_table
where type = 'desired_type') e
on days.date = e.event_date
My result set is not 1669 rows with full dates but only a few e.value, but instead just a row for each non-NULL days.date, e.value combination. Visually, instead of...
2009-01-01 | value 1
2009-01-02 | NULL
2009-01-03 | NULL
2009-01-04 | value 2
2009-01-05 | NULL
...
...I'm getting...
2009-01-01 | value 1
2009-01-04 | value 2
...
I'd expect this with an inner join, not a left join from days to e.