title: Working with where clauses inside views
body: <pre><code>CREATE VIEW summary AS  
  SELECT sales.inventory_id,
         sum(sales.value) AS value,
         count(sales.*) AS sales_n,
  FROM promotion
  JOIN sales USING (promotion_id)
  GROUP BY sales.inventory_id
  ;
  </code></pre>
  
  <ol>
  <li>This is a simplified query of a problem that I am dealing with</li>
  <li>However, I would like to be able to add a <code>WHERE</code> clause into the view. Something like this <code>WHERE promotion.created_at &gt; ?</code></li>
  </ol>
  
  <p>QUESTION:</p>
  
  <p>How should I modify the view so that I can do something like this:</p>
  
  <pre><code>SELECT * 
  FROM summary 
  WHERE promotion.created_at &gt; [timestamp]
  </code></pre>
  
  <p>I am currently not able to do this because there is a <code>GROUP BY</code> on <code>inventory_id</code> so <code>promotion.created_at</code> is not captured</p>