1

I am trying to generate a series of 48 periods x days into the future, and displaying matching data from a source table (T1) where available, however this just seems to act like an inner join and only displays rows which have a matching results from T1?

select
seq.date,
t1.date,
hh.period,
t1.period
From

myTable t1
right outer  join  (select date(date) from generate_series(current_date,current_date + '12 days'::interval ,'1 day'::interval) date)as  seq 
 ON (seq.date= t1.date)
right outer join (select period from generate_series (1,48) period) hh 
ON (hh.period = t1.period)

1 Answer 1

1

Cross join the series and then left join the table

Cellphone...

select seq.date, t1.date, hh.period, t1.period From (select date(date) 
from generate_series(current_date,current_date + '12 days'::interval ,'1 day'::interval) date)as seq 
cross join (select period from generate_series (1,48) period) hh
Left join my table
 ON (hh.period = t1.period)
And (seq.date= t1.date)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.