title: update only rows with max(id) with condition
body: <p>I can't find a solution for my problem..</p>
  
  <p>Let's say we have a simple table like this :</p>
  
  <ul>
  <li>id</li>
  <li>group_id</li>
  <li>flag</li>
  </ul>
  
  <p>For the moment, the <code>flag</code> column is set to 0.</p>
  
  <p>I want to update this table and set the <code>flag</code> to 1 only for rows that have the <em>greatest</em> (newest)<code>id</code> when grouped by <code>group_id</code>.</p>
  
  <p>I have been testing a lot of things, without success.</p>
  
  <p>Example: </p>
  
  <pre><code>id: 1, group_id: 1, flag: 0
  id: 2, group_id: 1, flag: 0
  id: 3, group_id: 1, flag: 0
  id: 4, group_id: 2, flag: 0
  id: 5, group_id: 2, flag: 0
  </code></pre>
  
  <p>Will become :</p>
  
  <pre><code>id: 1, group_id: 1, flag: 0
  id: 2, group_id: 1, flag: 0
  id: 3, group_id: 1, flag: 1
  id: 4, group_id: 2, flag: 0
  id: 5, group_id: 2, flag: 1
  </code></pre>