title: How to sum the computed rows in SQL?
body: <p><strong>QUERY:</strong></p>
  <pre><code>   SELECT name, 
      Sum(CASE WHEN month(date) in (1,2) THEN  amnt END ) as part1, 
      Sum(CASE WHEN month(date) in (3,4) THEN amnt END )as part2, 
      Sum(CASE WHEN month(date) in (5,6) THEN amnt END )as part3,
      Sum(CASE WHEN month(date) in (7,8) THEN amnt END )as part4,
      Sum(CASE WHEN month(date)  in (9,10) THEN amnt END )as part5,
      Sum(CASE WHEN month(date)  in (11,12) THEN amnt END )as part6
     FROM table1 GROUP BY name;
  </code></pre>
  <p><strong>CURRENT OUTPUT:</strong></p>
  <pre><code>--------+----------+----------+----------+----------+----------+----------+
  | name    | part1    |    part2 |    part3 |    part4 |    part5 |    part6 |
  +---------+----------+----------+----------+----------+----------+----------+
  | A       |     NULL |     NULL |     NULL |     NULL |     NULL |    29400 |
  | B       |     NULL |     NULL |     NULL |     NULL |     NULL |     1900 |
  | C       |     2330 |     2330 |     2330 |     2330 |     2330 |    16310 |
  | D       |     NULL |     NULL |     NULL |     NULL |     NULL |     8210 |
  | E       |     1782 |     1782 |     1782 |     1782 |     3564 |     1782 |
  | F       |     NULL |     NULL |     NULL |     NULL |     NULL |     7700 |
  </code></pre>
  <p><strong>REQUIRED OUTPUT - 1:</strong> How to compute the total column which is the sum of the amounts present in each row of all segments?</p>
  <pre><code>--------+----------+----------+----------+----------+----------+----------+ ----------- +
  | name    | part1    |    part2 |    part3 |    part4 |    part5 |    part6 |  Total    | 
  +---------+----------+----------+----------+----------+----------+----------+-----------+
  | A       |     NULL |     NULL |     NULL |     NULL |     NULL |    29400 |  29400    |
  | B       |     NULL |     NULL |     NULL |     NULL |     NULL |     1900 |  1900     |
  | C       |     2330 |     2330 |     2330 |     2330 |     2330 |    16310 |  27960    |
  | D       |     NULL |     NULL |     NULL |     NULL |     NULL |     8210 |  8210     |
  | E       |     1782 |     1782 |     1782 |     1782 |     3564 |     1782 |  12474    |
  | F       |     NULL |     NULL |     NULL |     NULL |     NULL |     7700 |  7700     |
  </code></pre>
  <p><strong>REQUIRED OUTPUT - 2:</strong> How to compute the total number of active parts, the part in which the value of the column is not NULL?</p>
  <pre><code>--------+----------+----------+----------+----------+----------+----------+ --------- +-------+
  | name    | part1    |    part2 |    part3 |    part4 |    part5 |    part6 |  Total  | Active| 
                                                                                        | Parts |
  +---------+----------+----------+----------+----------+----------+----------+-----------+------
  | A       |     NULL |     NULL |     NULL |     NULL |     NULL |    29400 |  29400  |  1    |
  | B       |     NULL |     NULL |     NULL |     NULL |     NULL |     1900 |  1900   |  1    |
  | C       |     2330 |     2330 |     2330 |     2330 |     2330 |    16310 |  27960  |  6    |
  | D       |     NULL |     NULL |     NULL |     NULL |     NULL |     8210 |  8210   |  1    |
  | E       |     1782 |     1782 |     1782 |     1782 |     3564 |     1782 |  12474  |  6    |
  | F       |     NULL |     NULL |     NULL |     NULL |     NULL |     7700 |  7700   |  1    |
  
  
  </code></pre>