title: MySQL calculate percent of total in a group_by / where condition
body: <p>I'm using MySQL 5.7 and would like to calculate a percentage of edited posts for a user during a specific time.</p>
  <p>Normally, I'd do this as two separate queries but I'm pretty sure could be done with a single query. I have a group of users who have edited posts and would like to get a count of the number of edited posts per user. Like so:</p>
  <pre><code>select count(*) as edited_post_count, 
         user_id 
  from posts 
  where edited_at between '2022-05-31' and '2022-06-06' 
  group by user_id 
  order by edited_post_count desc;
  </code></pre>
  <p>Now, I'd like to figure out the total number of posts they have all-time to be able to say 10 of 80 posts were edited during this time. edited_at would be null if they haven't edited (and yes should be last_edited_at). How could I add this to this query?</p>
  <p><strong>posts</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>body</th>
  <th>user_id</th>
  <th>edited_at</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>&quot;what&quot;</td>
  <td>1</td>
  <td>2022-06-01</td>
  </tr>
  <tr>
  <td>2</td>
  <td>&quot;ever&quot;</td>
  <td>1</td>
  <td>NULL</td>
  </tr>
  <tr>
  <td>3</td>
  <td>&quot;more&quot;</td>
  <td>2</td>
  <td>2022-06-03</td>
  </tr>
  </tbody>
  </table>
  </div>