title: SQL / stored procedure - detect when changes happen within a list of specified values
body: <p>I need to create a report that returns customer accounts whose account type have changed to or from this list of account_types:</p>
  <pre><code>('CAM', 'CAMADP', 'CAMHD', 'CAMHDADP', 'DIST', 'DISTADP', 'GAM', 'GAMADP', 'LAM', 'LAMADP')
  </code></pre>
  <p>or accounts that have been deactivated.</p>
  <p>Let's say I have this table today:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>client</th>
  <th>account_type</th>
  <th>customer_org_ID</th>
  <th>insert_date</th>
  <th>update_date</th>
  <th>active_Y_N</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Google</td>
  <td>GAM</td>
  <td>C000001</td>
  <td>2006-05-04 09:15:34</td>
  <td>2020-05-04 06:01:16</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Netflix</td>
  <td>LAM</td>
  <td>C000002</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-09-04 08:35:34</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Nordstrom</td>
  <td>DIST</td>
  <td>C000003</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-05-04 02:15:34</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Costco</td>
  <td>CAMHDADP</td>
  <td>C000004</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-05-04 09:36:34</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Boeing</td>
  <td>CAMHD</td>
  <td>C000005</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-05-04 12:15:45</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Samsung</td>
  <td>DISTADP</td>
  <td>C000006</td>
  <td>2006-05-04 09:15:34</td>
  <td>2020-06-15 01:10:16</td>
  <td>Y</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Let's say I come into work tomorrow and there have been changes to rows 1, 2, 3, 5, and 6 (seen in bold).</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>client</th>
  <th>account_type</th>
  <th>customer_org_ID</th>
  <th>insert_date</th>
  <th>update_date</th>
  <th>active_Y_N</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Google</td>
  <td><strong>CAM</strong></td>
  <td>C000001</td>
  <td>2006-05-04 09:15:34</td>
  <td><strong>2021-11-03 12:40:41</strong></td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Netflix</td>
  <td><strong>DISTADP</strong></td>
  <td>C000002</td>
  <td>2006-05-04 09:15:34</td>
  <td><strong>2021-11-03 12:40:41</strong></td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Nordstrom</td>
  <td><strong>GAMADP</strong></td>
  <td>C000003</td>
  <td>2006-05-04 09:15:34</td>
  <td><strong>2021-11-03 12:40:41</strong></td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Costco</td>
  <td>CAMHDADP</td>
  <td>C000004</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-05-04 09:36:34</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Boeing</td>
  <td><strong>UNKWN</strong></td>
  <td>C000005</td>
  <td>2006-05-04 09:15:34</td>
  <td><strong>2021-11-03 12:40:41</strong></td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Samsung</td>
  <td>DISTADP</td>
  <td>C000006</td>
  <td>2006-05-04 09:15:34</td>
  <td><strong>2021-11-03 12:40:41</strong></td>
  <td><strong>N</strong></td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I need a SQL query or a stored procedure that will return these four rows of data since there were updates made to their account_type within the list of <code>account_types</code> that I mentioned in the beginning. Or the account has been deactivated.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>client</th>
  <th>account_type</th>
  <th>customer_org_ID</th>
  <th>insert_date</th>
  <th>update_date</th>
  <th>active_Y_N</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>Google</td>
  <td>CAM</td>
  <td>C000001</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-11-03 12:40:41</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Netflix</td>
  <td>DISTADP</td>
  <td>C000002</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-11-03 12:40:41</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Nordstrom</td>
  <td>GAMADP</td>
  <td>C000003</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-11-03 12:40:41</td>
  <td>Y</td>
  </tr>
  <tr>
  <td>Samsung</td>
  <td>DISTADP</td>
  <td>C000006</td>
  <td>2006-05-04 09:15:34</td>
  <td>2021-11-03 12:40:41</td>
  <td>N</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I am working in DB2 LUW database. Unfortunately I cannot add any new columns to the database I'm querying the data from.</p>