title: How can I write this MySQL query?
body: <p>We have a system where users send in bags of goods to us.</p>
  
  <p>I am trying figure out how to pull users with a calculated field for the date they sent their 3rd bag of goods.  The state on the history table that would indicate this event is "processed".  If I wanted to just get the received date for a particular bag I would write:</p>
  
  <pre><code>SELECT bags.created_at FROM history 
  WHERE history.state='received' AND history.bag_id LIMIT 1
  </code></pre>
  
  <p>Here are our tables:</p>
  
  <pre><code>users
    id
  
  bags
    user_id
  
  history
    state
    bag_id
    created_at
  </code></pre>
  
  <p>The end goal is a select query that gives us user records and adds the "field" 3rd_bag_received_at</p>
  
  <p>Any ideas?</p>