title: Sum Value as per case in MySql
body: <p>As per below MySql Query fetch product count correctly see the red box in image. I need if <strong>icat_id</strong> 444 than 448 count (158) <strong>SUM</strong> in <strong>category_count</strong> (435) of <strong>icat_id</strong> 444.</p>
  <p>After this <strong>icat_id</strong> 444 total sum of 435 + 158 = 593.</p>
  <p>But Case not working properly. Please help</p>
  <pre><code>SELECT c.vcategory, c.icat_id, 
  COUNT( DISTINCT product_cat_rel_1.iprod_id) AS category_count, 
  UPPER(REGEXP_REPLACE(CONCAT(' ', c.vcategory), ' (.)[^ ]+', '\\1' ))  AS category_name,
  SUM(CASE WHEN (c.icat_id = '444') THEN 1 WHEN (c.icat_id = '448') THEN 1 ELSE 0 END) AS tt
  
  
   FROM product 
   INNER JOIN product_cat_rel_1 ON product_cat_rel_1.iprod_id = product.iprod_id 
   INNER JOIN product_price ON product_price.iprod_id = product.iprod_id 
   INNER JOIN category as c ON c.icat_id = product_cat_rel_1.icat_id 
   WHERE product.estatus='1' 
   AND product_cat_rel_1.icat_id in (444,448,450,454,471,549,592,741,765,782) 
   GROUP BY product_cat_rel_1.icat_id
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Mmp7Y.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mmp7Y.jpg" alt="enter image description here" /></a></p>