title: How do I select data going back a period of time for each group?
body: <p>I want for each group <code>id</code> to get the latest week's worth of data. Not from a specific date, but counting backwards from the <code>MAX(startTime)</code> of each individual group.</p>
  <p>However, the following does not seem to work. I assume it's because <code>startTime</code> in each group (a single value) is <code>BETWEEN</code>ed by itself? Otherwise, how do I keep it in my filter?</p>
  <pre class="lang-sql prettyprint-override"><code>SELECT
      id
    , startTime
  FROM MyTable
  GROUP BY id, startTime
  HAVING startTime BETWEEN MAX(startTime) - INTERVAL 1 WEEK AND MAX(startTime)
  </code></pre>
  <p>What's the right query?</p>
  <p>Also, in my case it has to work with MySQL 5.7.</p>