title: how to sum sql column value into a separate column ? here to sum up NPM,NPF,NPC to a new column
body: <pre><code>SELECT DATE_FORMAT(e.`date_created`,'%d-%b-%Y') AS DATE,
         SUM(CASE WHEN ps.Gender = 'M'
             AND e.encounter_type&lt;='6'
             AND DATEDIFF(CURDATE(), ps.birthdate)&gt;4381 THEN 1 ELSE 0 END) AS **NPM**,
         SUM(CASE WHEN ps.Gender = 'F'
                   AND e.encounter_type&lt;='6'
                   AND DATEDIFF(CURDATE(), ps.birthdate)&gt;4381 
                  THEN 1 ELSE 0 END) AS **NPF**,
         SUM(CASE WHEN DATEDIFF(CURDATE(), ps.birthdate)&lt;=4380
                   AND e.encounter_type&lt;='6' 
                  THEN 1 ELSE 0 END) AS **NPC**,
  SUM(CASE WHEN ps.Gender = 'M'
      AND e.encounter_type&gt;'6'
      AND DATEDIFF(CURDATE(), ps.birthdate)&gt;4381 THEN 1 ELSE 0 END) AS OPM,
  SUM(CASE WHEN ps.Gender = 'F'
      AND e.encounter_type&gt;'6'
      AND DATEDIFF(CURDATE(), ps.birthdate)&gt;4381 THEN 1 ELSE 0 END) AS OPF,
  SUM(CASE WHEN DATEDIFF(CURDATE(), ps.birthdate)&lt;=4380
      AND e.encounter_type&gt;'6' THEN 1 ELSE 0 END) AS OPC,
  COUNT(e.`patient_id`) AS total
  FROM patient_search ps
  LEFT JOIN
  (SELECT e.`encounter_id`,
          e.`encounter_type`,
          e.`patient_id`,
          e.`date_created`,
          e.`creator`
   FROM encounter AS e
   GROUP BY e.`creator`,
            e.`date_created`) AS e ON e.patient_id=ps.patient_id
  LEFT JOIN
  (SELECT oo.`concept_id`,
          oo.`value_text`,
          oo.`encounter_id`
   FROM obs AS oo
   WHERE oo.`concept_id`='4086')AS eId ON e.`encounter_id`=eId.encounter_id
  GROUP BY DATE_FORMAT(e.`date_created`,'%Y-%m-%d')
  </code></pre>