title: Update only the greatest row - Sequential Based Update
body: <p>I want to write a query to find the LOWEST SEQUENCE for status = REQUEST_PENDING then update it after a certain condition.</p>
  <p>For example:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>person_name</th>
  <th>status</th>
  <th>sequence</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>a</td>
  <td>request_progressed</td>
  <td>1</td>
  </tr>
  <tr>
  <td>b</td>
  <td>request_pending</td>
  <td>2</td>
  </tr>
  <tr>
  <td>c</td>
  <td>request_pending</td>
  <td>3</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>If the person named A is done, it's status would change from &quot;request_progressed&quot; to &quot;request_done&quot;; then the next person B will have his status changed to &quot;request_progressed&quot; while the person C stays the same because its sequence is the 3rd.</p>
  <p>So I just need to know how do I change the person B status by finding the lowest sequence which has &quot;request_pending&quot; status and THERE IS (SUPPOSED TO BE) ONLY ONE &quot;request_progressed&quot; on the table that is why when it is updated to &quot;request_done&quot; the next &quot;request_pending&quot; need to be updated to &quot;request_progressed&quot;.</p>
  <p>I tried the following:</p>
  <pre><code>update table
  set status = 'request_progressed'
  where status = 'pending' AND sequence = min(sequence)
  </code></pre>