title: postgres similar to pandas melt, date between two dates
body: <p>df</p>
  <pre><code>created_at invoice_no period_start  period_end  nett 
  2021-09-01   A          2021-09-01  2022-08-31  120€
  2021-12-01   B          2022-01-01  2022-06-30  120€   
  </code></pre>
  <p>Expected output</p>
  <pre><code>invoice_month  invoice_no nett_per_month
  2021-09-01     A                10€
  2021-10-01     A                10€
  2021-11-01     A                10€
  2021-12-01     A                10€
  ....
  2022-08-01     A                10€
  
  ....
  2021-12-01     B               null
  2022-01-01     B                20€
  2022-02-01     B                20€
  2022-03-01     B                20€
  ....
  2022-06-01     B                20€   
  </code></pre>
  <p>Based on df, I would like to transform df into the expected output.
  I believe that a similar approach is possible using pandas melt (in Python).
  I can think of the logic to do it, but not sure about the code.</p>
  <ol>
  <li>Use a cross join to another table so that we have a column that consists of all the months</li>
  <li>If the month column is between period start and period end, divide the nett column by the number of months in between period start and period end.
  If the period start or period end is null, take the created_at as the invoice_month.</li>
  </ol>