title: Finding Known State Changes in SQL
body: <p>I am using SQL to detect a known state change in a table. Please see the columns below where the state moves from GOOD, BAD and UNDEFINED.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">date</th>
  <th style="text-align: center;">row</th>
  <th style="text-align: right;">status</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">20/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">UNDEFINED</td>
  </tr>
  <tr>
  <td style="text-align: left;">19/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">UNDEFINED</td>
  </tr>
  <tr>
  <td style="text-align: left;">18/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">BAD</td>
  </tr>
  <tr>
  <td style="text-align: left;">17/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">GOOD</td>
  </tr>
  <tr>
  <td style="text-align: left;">16/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">GOOD</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Now see the column below where the state skips the BAD state and goes directly to UNDEFINED.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: left;">date</th>
  <th style="text-align: center;">row</th>
  <th style="text-align: right;">status</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: left;">20/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">UNDEFINED</td>
  </tr>
  <tr>
  <td style="text-align: left;">19/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">UNDEFINED</td>
  </tr>
  <tr>
  <td style="text-align: left;">18/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">GOOD</td>
  </tr>
  <tr>
  <td style="text-align: left;">17/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">GOOD</td>
  </tr>
  <tr>
  <td style="text-align: left;">16/08/2022</td>
  <td style="text-align: center;">Z</td>
  <td style="text-align: right;">GOOD</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>How can i detect the date on which the state entered UNDEFINED from GOOD. i.e my result should give me the two rows with date 19/08/2022 and 18/08/2022 capturing the change.</p>