title: Use SQL statements to construct an aggregator to calculate the data sum of a matrix
body: <p>I have recently tried to construct an aggregator to calculate the sum of the entire table data. Do you have any opinions?</p>
  
  <p>Following is my table structure and data：</p>
  
  <pre><code>CREATE TABLE matrix (
  id INT NOT NULL PRIMARY KEY UNIQUE,
  room INT NOT NULL,
  salary INT NOT NULL, 
  time INT NOT NULL);
  
  
  
   id | room | salary | time 
  ----+------+--------+------
    1 |  101 |    100 |    7
    2 |  205 |    150 |    8
    3 |  304 |    160 |    7
    4 |  106 |    200 |    8
  </code></pre>
  
  <p>I want to calculate the total of the entire table data by constructing an aggregator so that its output looks like this:</p>
  
  <pre><code>sum
  ------
  1366
  </code></pre>
  
  <p>Are there any good solutions?</p>