title: how i can use if else into sum - mysql statement
body: <p>i could not find the correct query of sql, how i can use if else statement in sum?? i want add <code>sum(if(noresult),0,number)</code> if there is no any result. but it doesnt work.</p>
  
  <pre><code>INNER JOIN ( SELECT  
                  COUNT(*), SUM(cekilen_tutar)  AS bal_total 
              FROM alinanbaliklar 
              WHERE user_id = 1  
              GROUP BY user_id )balik
  INNER JOIN ( SELECT 
                   COUNT(*), SUM(cekilen_tutar)  AS dom_total 
              FROM alinandomuzlar 
              WHERE user_id = 1  
              GROUP BY user_id )domuz
  INNER JOIN ( SELECT   
                    COUNT(*),SUM(cekilen_tutar)  AS seb_total 
               FROM alinanmeyvesebzeler 
               WHERE user_id = 1 
               GROUP BY user_id )sebze
  INNER JOIN ( SELECT  
                   COUNT(*), SUM(cekilen_tutar)  AS ag_total 
              FROM alinanagaclar 
              WHERE user_id = 1 
              GROUP BY user_id )agac
  </code></pre>