title: Filtering and restricting in query
body: <p>I would like to seek some help in my query...i want to do is if specific <code>atic</code> and <code>oaic</code> is empty in the table...the <code>interview_sum</code> or <code>other_sum</code> to that specific <code>atic</code> <code>oaic</code> should be empty too....can anyone know how to do that?</p>
  
  <p>picture of current output:<img src="https://i.stack.imgur.com/5vQjQ.png" alt="enter image description here"></p>
  
  <p>current query: my query still gives numbers to other_sum or interview_sum even its empty.</p>
  
  <pre><code>SELECT DISTINCT 
  IF(t.inttotal=NULL,0,(SELECT SUM(t2.inttotal)
   FROM app_interview2 AS t2 
   WHERE t2.atic = t.atic AND t2.inttotal&gt;0)/7)
   AS interview_sum,
  
  IF(o.ototal=NULL,0,(SELECT SUM(o2.ototal)
   FROM other_app2 AS o2 
   WHERE o2.oaic = o.oaic AND o2.ototal&gt;0)/7)
   AS other_sum,
  
  atid,
  atic,
  atname,
  region,
  town,
  uniq_id,
  position,
  salary_grade,
  salary
  FROM app_interview2 AS t, other_app2 AS o
  GROUP BY t.atname HAVING COUNT(DISTINCT t.atic) 
  </code></pre>