title: How to cross join generate_series and table with Redshift?
body: <p>I would like to cross join a table with a series of data generated by the <code>generate_series()</code> function to generate 36 month.</p>
  
  <p>I don't know how to make a cross join that works with this configuration.</p>
  
  <p>Knowing that:</p>
  
  <ul>
  <li><p>I can't create a new table to store the result of the generate_series()</p></li>
  <li><p>And using Redshift I don't have a recent version of PostgreSQL I'm forced to make my <code>generated_series()</code> like this for it to work.</p></li>
  </ul>
  
  <p>I have tried this without success.</p>
  
  <pre class="lang-sql prettyprint-override"><code>WITH sales AS (
  SELECT 
     department
    ,product
    ,count(*) as invoice 
  
  FROM table 
    WHERE  product SIMILAR TO '%(Apple|Lemon|Salt)%' 
    AND department is not NULL 
    group by department , product order by department , product ASC
  ),
  
  
  date_gen as( SELECT (date_trunc('month', CURRENT_DATE::TIMESTAMP))  - (i * interval '1 month') as date_datetime 
  FROM generate_series(1,36) i 
  )
  
  SELECT * FROM date_gen
  CROSS JOIN sales;
  </code></pre>
  
  <p>If you have pro tips :)</p>