title: How can I get a count of unique parents grouped by child's last created date?
body: <p>A <code>parent</code> has many <code>children</code>, where each <code>child</code> has a <code>created_at</code> column.</p>
  
  <p>Let's assume the data looks something like this:</p>
  
  <pre><code>Parent 1:  
  - Child 1, created_at (last week sometime)
  - Child 2, created_at (yesterday)
  Parent 2:
  - Child 3, created_at (today)
  Parent 3:
  - Child 4, created_at (today)
  </code></pre>
  
  <p>Using PostgreSQL through Rails, how can I get a count of unique <code>parents</code> grouped by <code>child</code>'s most recent <code>created_at</code>? The output should look something like this: <code>[Yesterday: 1, Today: 2]</code>. Note that the <code>created_at</code> from last week is not returned since the parent has a more recent child.</p>
  
  <p>I'll take either raw SQL or ActiveRecord query form. Thanks!</p>