title: RIGHT OUTER JOIN returns empty results with WHERE
body: <p>I need to produce a report of all records (businesses) created by a particular user each month over last months. I produced the following query and expect it to provide me with a row for each month. However, this user didn't create any records (businesses) these months so I get an empty result <code>[]</code>.</p>
  
  <p>I'm still expecting to receive a row for each month, since I'm selecting a <code>generate_series</code> column using RIGHT OUTER JOIN but it doesn't happen. </p>
  
  <pre><code>start = 3.months.ago
  stop  = Time.now
  
  new_businesses = Business.select(
      "generate_series, count(id) as new").
    joins("RIGHT OUTER JOIN ( SELECT
      generate_series(#{start.month}, #{stop.month})) series
      ON generate_series = date_part('month', created_at)
    ").
    where(created_at: start.beginning_of_month .. stop.end_of_month).
    where(author_id: creator.id).
    group("generate_series").
    order('generate_series ASC')
  </code></pre>
  
  <p>How can I change my query to get a row for each month instead of an empty result? I'm using PosgreSQL.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>This code works:</p>
  
  <pre><code>new_businesses = Business.select(
      "generate_series as month, count(id) as new").
    joins("RIGHT OUTER JOIN ( SELECT
      generate_series(#{start.month}, #{stop.month})) series
      ON (generate_series = date_part('month', created_at)
        AND author_id = #{creator.id}
        AND created_at BETWEEN '#{start.beginning_of_month.to_formatted_s(:db)}' AND
          '#{stop.end_of_month.to_formatted_s(:db)}'
      )
    ").
    group("generate_series").
    order('generate_series ASC')
  </code></pre>