Postgres - Inject 0 values when rows do not exist
You need to create a pseudo date range and join to it...  Like such:

select generate_series('2014-01-01'::timestamp, '2014-10-01'::timestamp, '1 month'::interval)::date;


Once you have your series, you can join to it and use COALESCE to fill in 0's for where there is no data..

WITH days AS (
  select generate_series('2014-01-01'::timestamp, '2014-10-01'::timestamp, '1 month'::interval)::date AS day
) SELECT
  d.day, COALESCE(t1.col1, 0) AS value
FROM days d
LEFT JOIN &lt;something with a date&gt; t1 on d.day = t1.day


If you need to join to something that DOESN'T have a date (for example, your "person" table above), then just join with the condition being "TRUE" (to make a cartesian join, so every person gets every day)

WITH days AS (
  select generate_series('2014-01-01'::timestamp, '2014-10-01'::timestamp, '1 month'::interval)::date AS day
) SELECT
  d.day, COALESCE(t1.col1, 0) AS value
FROM days d
JOIN person p ON TRUE