我正在尝试在未来x天生成一系列48个周期,并在可用的源表(T1)中显示匹配数据,但这似乎就像内部联接一样,只显示具有匹配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)
答案 0 :(得分:1)
交叉加入该系列,然后离开加入表格
手机...
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)