title: How can I calculate the sum in a temporary column in SQL?
body: <p>I have this code:</p>
  
  <pre><code>SELECT
      ID,
      name,
      result,
      CASE
          WHEN result = 1 THEN 100
          WHEN result = 2 THEN 80
          ELSE NULL
      END AS TemporaryColumn
  FROM MyTable
  </code></pre>
  
  <p>And this is the table: </p>
  
  <pre><code>| ID | Name | result | TemporaryColumn |
  ----------------------------------------
  |  1 |  A   |   1    |      100        |
  ----------------------------------------
  |  2 |  B   |   1    |      100        |
  ----------------------------------------
  |  3 |  C   |   2    |      80         |
  ----------------------------------------
  |  1 |  A   |   2    |      80         |
  ----------------------------------------
  |  2 |  B   |   1    |      100        |
  ----------------------------------------
  |  3 |  C   |   2    |      80         |
  ----------------------------------------
  </code></pre>
  
  <p>I want to find the sum() of every ID, and the table should look like this:</p>
  
  <pre><code>| ID | Name | result | TemporaryColumn |
  ----------------------------------------
  |  1 |  A   |   1    |      180        |
  ----------------------------------------
  |  2 |  B   |   1    |      200        |
  ----------------------------------------
  |  3 |  C   |   2    |      160        |
  ----------------------------------------
  </code></pre>
  
  <p>How can I query this?</p>