title: Apply two query statments to a list of tables in sqlite3
body: <p>In my sqlite database I dynamically generate several (~150) tables, each representing a dataset consisting of a time stamp and a floating point value. These tables can each be described or generated by the following statement:</p>
  <pre><code>create table &quot;MY_FIRST_TABLE&quot;
  (
      Date  TIMESTAMP,
      Value REAL
  );
  
  create index &quot;ix_MY_FIRST_TABLE_Date&quot;
      on &quot;MY_FIRST_TABLE&quot; (Date);
  </code></pre>
  <p>Now I want to create a query to retrieve for every one of the tables the first and last date that has a valid value (not equal to None).</p>
  <p>I have already found out that I can query a list of all tables in my database with the following statement:</p>
  <pre><code>SELECT
      name
  FROM
      sqlite_schema
  WHERE
      type ='table' AND
      name NOT LIKE 'sqlite_%';
  </code></pre>
  <p>In addition, I have the two commands to query for each of the first and last date that has a valid value (not equal to None):</p>
  <pre><code>SELECT Date
  FROM &quot;MY_FIRST_TABLE&quot;
  WHERE Value is not null
  ORDER BY Date ASC
  LIMIT 1;
  
  SELECT Date
  FROM &quot;MY_FIRST_TABLE&quot;
  WHERE Value is not null
  ORDER BY Date DESC
  LIMIT 1;
  </code></pre>
  <p>Now my question is, how can I merge these three individual queries into a single statement to eventually get a table that contains the name of each table with their first and last date of valid values (not equal to None) as a result, like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Table</th>
  <th>First</th>
  <th>Last</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>FIRST_TABLE_NAME</td>
  <td>01.01.2011</td>
  <td>12.01.2021</td>
  </tr>
  <tr>
  <td>SECOND_TABLE_NAME</td>
  <td>05.01.2011</td>
  <td>05.02.2021</td>
  </tr>
  <tr>
  <td>THIRD_TABLE_NAME</td>
  <td>01.06.2011</td>
  <td>08.11.2021</td>
  </tr>
  </tbody>
  </table>
  </div>