title: how to auto compute my total grades to GEN_AVE?
body: <p>this is my table</p>
  
  <pre><code>CREATE TABLE `GRADES_Q1` (
  `Date_Modified` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `LRN` BIGINT(12) NOT NULL DEFAULT '0',
  `Last_Name` VARCHAR(50) NOT NULL,
  `First_Name` VARCHAR(50) NOT NULL,
  `Level` VARCHAR(3) NOT NULL,
  `Mother_Tongue` VARCHAR(50) NULL DEFAULT NULL,
  `Filipino` VARCHAR(50) NULL DEFAULT NULL,
  `English` VARCHAR(50) NULL DEFAULT NULL,
  `Science` VARCHAR(50) NULL DEFAULT NULL,
  `Math` VARCHAR(50) NULL DEFAULT NULL,
  `AP` VARCHAR(50) NULL DEFAULT NULL,
  `MAPEH` VARCHAR(50) NULL DEFAULT NULL,
  `Music` VARCHAR(50) NULL DEFAULT NULL,
  `Arts` VARCHAR(50) NULL DEFAULT NULL,
  `PE` VARCHAR(50) NULL DEFAULT NULL,
  `Health` VARCHAR(50) NULL DEFAULT NULL,
  `ESP` VARCHAR(50) NULL DEFAULT NULL,
  `Computer` VARCHAR(50) NULL DEFAULT NULL,
  `TLE` VARCHAR(50) NULL DEFAULT NULL,
  `CAT` VARCHAR(50) NULL DEFAULT NULL,
  `EPP` VARCHAR(50) NULL DEFAULT NULL,
  `GEN_AVE` VARCHAR(50) NULL DEFAULT NULL,
  PRIMARY KEY (`LRN`)
  )COLLATE='latin1_swedish_ci'
  ENGINE=InnoDB;
  </code></pre>
  
  <p>this is my query</p>
  
  <pre><code>UPDATE GRADES_Q1
  SET GEN_AVE = (SELECT sum(COALESCE(Mother_Tongue,0))
        + COALESCE(Filipino,0)
        + COALESCE(English,0)
        + COALESCE(Science,0)
        + COALESCE(Math,0)
        + COALESCE(AP,0)
        + COALESCE(MAPEH,0)
        + COALESCE(ESP,0)
        + COALESCE(Computer,0)
        + COALESCE(TLE,0)
        + COALESCE(CAT,0)
        + COALESCE(EPP,0)
        / (12 - (select sum(case when ENGLISH is null then 1 else 0 end
        + case when Math is null then 1 else 0 end
        + case when ESP is null then 1 else 0 end
        + case when Mother_Tongue is null then 1 else 0 end
        + case when Computer is null then 1 else 0 end
        + case when MAPEH is null then 1 else 0 end
        + case when Science is null then 1 else 0 end
        + case when AP is null then 1 else 0 end
        + case when EPP is null then 1 else 0 end
        + case when TLE is null then 1 else 0 end
        + case when CAT is null then 1 else 0 end
        + case when AP is null then 1 else 0 end)
  
           as grandtotals)))
  </code></pre>
  
  <p>When I run query, I Want to compute (Total sum of grades)/(16-number of null columns) and set it to GEN_AVE or general average.</p>
  
  <p>For Example, (i want it like this)</p>
  
  <p><code>Math Science AP   EPP   TLE   GEN_AVE
  99    89     90    99    87     92.8
  </code>(computed as sum of grades / number of non null columns.</p>
  
  <p>My Problem, it gives me strange result to my GEN_AVE but no errors (yey!). 
  Please Help. Thanks.</p>