Postgresql 展开Postgres中的行

Postgresql 展开Postgres中的行,postgresql,Postgresql,我有一张这样的表格: INITIAL_DATE Quantity Value Total 10/10/2020 3 100.0 300.0 如何查询以获得此结果: 10/10/2020 - 100.00 10/11/2020 - 100.00 10/12/2020 - 100.00 分期付款之间的日期为一个月。您可以使用generate_series() select t.init

我有一张这样的表格:

INITIAL_DATE         Quantity     Value     Total
10/10/2020               3        100.0     300.0
如何查询以获得此结果:

 10/10/2020  -   100.00   
 10/11/2020  -   100.00
 10/12/2020  -   100.00

分期付款之间的日期为一个月。

您可以使用
generate_series()

select t.initial_date + make_interval(months => g.i::int) as the_date,
       value
from the_table t
  cross join generate_series(1, t.quantity) as g(i)
order by 1