title: How to create a query to get table from multiple columns
body: <p>I am creating a table of all the users listing their username and pending questions with total number of allotted question.</p>
  <p>I have 2 tables
  first one contain the username,initial question number and final question number columns and second table contain the timestamp username and submitted question number</p>
  <p><strong>first db table</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>username</th>
  <th>first que</th>
  <th>last que</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>usera</td>
  <td>101</td>
  <td>200</td>
  </tr>
  <tr>
  <td>userb</td>
  <td>201</td>
  <td>300</td>
  </tr>
  <tr>
  <td>userc</td>
  <td>301</td>
  <td>400</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><strong>second db table</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>username</th>
  <th>submitted question number</th>
  <th>timestamp</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>usera</td>
  <td>103</td>
  <td>13-06-2022</td>
  </tr>
  <tr>
  <td>usera</td>
  <td>102</td>
  <td>11-06-2022</td>
  </tr>
  <tr>
  <td>userb</td>
  <td>201</td>
  <td>12-06-2022</td>
  </tr>
  <tr>
  <td>usera</td>
  <td>101</td>
  <td>09-06-2022</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>so i want to output it as a username,total question allotted, pending question</p>
  <p><strong>Output i want on webpage</strong></p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>username</th>
  <th>total question allotted</th>
  <th>pending question</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>usera</td>
  <td>99</td>
  <td>96</td>
  </tr>
  <tr>
  <td>userb</td>
  <td>99</td>
  <td>98</td>
  </tr>
  <tr>
  <td>usera</td>
  <td>99</td>
  <td>99</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>total pending question must be calculated as by (total questions in series - total submitted questions)</p>