title: Generated column from another table's column
body: <p><code>Transaction</code> table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Name</th>
  <th>Price</th>
  <th>Amount Paid</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>Bruce Wayne</td>
  <td>10.0</td>
  <td>5.0</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Lois Lane</td>
  <td>33.33</td>
  <td>22.22</td>
  </tr>
  <tr>
  <td>3</td>
  <td>Clark Kent</td>
  <td>44.4</td>
  <td>44.4</td>
  </tr>
  <tr>
  <td>4</td>
  <td>Bruce Wayne</td>
  <td>15.0</td>
  <td>20.0</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><code>Person</code> table:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>Name</th>
  <th>Total Price</th>
  <th>Total Paid</th>
  <th>Payment Due</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>Bruce Wayne</td>
  <td>25.0</td>
  <td>25.0</td>
  <td>0.00</td>
  </tr>
  <tr>
  <td>2</td>
  <td>Lois Lane</td>
  <td>33.33</td>
  <td>22.22</td>
  <td>11.11</td>
  </tr>
  <tr>
  <td>3</td>
  <td>Clark Kent</td>
  <td>44.4</td>
  <td>44.4</td>
  <td>0.00</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p><code>Transaction</code> table is connected to application and <code>Person</code> table has <code>ID</code> and <code>Name</code>. <code>PaymentDue</code> column calculates <code>TotalPrice - TotalPaid</code>. Both <code>TotalPrice</code> and <code>TotalPaid</code> columns are empty and have default value of <code>0.00</code>.</p>
  <p>I want to generate/update <code>TotalPrice</code> and <code>TotalPaid</code>  from <code>Transaction</code> table's <code>Price</code> and <code>Amount Paid</code> column where <code>Transaction.Name = Person.Name</code>.</p>
  <p>I'm trying to create table with :</p>
  <pre><code>CREATE TABLE &quot;Person&quot; (
      &quot;ID&quot;    INTEGER NOT NULL UNIQUE,
      &quot;Name&quot;  TEXT,
      &quot;TotalPrice&quot;    REAL AS (SUM(&quot;main.Transaction.Price&quot;) WHERE &quot;main.Transaction.Name&quot; = &quot;Name&quot;),
      &quot;TotalPaid&quot; REAL DEFAULT 0.00,
      &quot;PaymentDue&quot;    REAL NOT NULL AS (&quot;TotalPrice&quot; - &quot;TotalPaid&quot;),
      PRIMARY KEY(&quot;ID&quot; AUTOINCREMENT)
  );
  </code></pre>
  <p>It's giving an error:</p>
  <blockquote>
  <p>Execution finished with errors. Result: near &quot;WHERE&quot;: syntax error At
  line 1: CREATE TABLE &quot;Person&quot; (   &quot;ID&quot;    INTEGER NOT NULL UNIQUE,
  &quot;Name&quot;  TEXT,   &quot;TotalPrice&quot;    REAL AS (SUM(&quot;main.Transaction.Price&quot;)
  WHERE</p>
  </blockquote>
  <p>I also tried :</p>
  <pre><code>&quot;TotalPrice&quot;    REAL AS (SELECT SUM(&quot;main.Transaction.Price&quot;) WHERE &quot;main.Transaction.Name&quot; = &quot;Name&quot;),
  </code></pre>
  <p>Error :</p>
  <blockquote>
  <p>Execution finished with errors. Result: near &quot;SELECT&quot;: syntax error At
  line 1: CREATE TABLE &quot;Person&quot; (   &quot;ID&quot;    INTEGER NOT NULL UNIQUE,
  &quot;Name&quot;  TEXT,   &quot;TotalPrice&quot;    REAL AS (SELECT</p>
  </blockquote>
  <p>Also :</p>
  <pre class="lang-sql prettyprint-override"><code>&quot;TotalPrice&quot;    REAL AS (SUM(t.Price) FROM Transaction t WHERE &quot;main.Transaction.Name&quot; = &quot;Name&quot;),
  </code></pre>
  <p>Error:</p>
  <blockquote>
  <p>Near &quot;FROM&quot; syntax error</p>
  </blockquote>
  <p>This app is to check customer/vendor payments and inventory management. I created <code>Person</code> table with :</p>
  <pre><code>CREATE TABLE &quot;Person&quot; (
      &quot;ID&quot;    INTEGER NOT NULL UNIQUE,
      &quot;Name&quot;  TEXT,
      &quot;TotalPrice&quot;    REAL DEFAULT 0.00,
      &quot;TotalPaid&quot; REAL DEFAULT 0.00,
      &quot;PaymentDue&quot;    REAL NOT NULL AS (&quot;TotalPrice&quot; - &quot;TotalPaid&quot;),
      PRIMARY KEY(&quot;ID&quot; AUTOINCREMENT)
  );
  </code></pre>
  <p>And <code>Transaction</code> table :</p>
  <pre><code>CREATE TABLE &quot;Transaction&quot; (
      &quot;ID&quot;    INTEGER NOT NULL UNIQUE,
      &quot;Name&quot;  TEXT,
      &quot;Price&quot; REAL  NOT NULL DEFAULT 0.00,
      &quot;AmountPaid&quot;    REAL NOT NULL DEFAULT 0.00,
      PRIMARY KEY(&quot;ID&quot; AUTOINCREMENT)
  );
  </code></pre>
  <p>I can do update query but don't know how to use <code>SUM()</code>.</p>