title: mysql get difference of two sum on the same table
body: <p>how can i get the result in just one query instead of this one:</p>
  
  <pre><code>SELECT SUM(`quantity`) as type0 FROM `fruits_delivery` 
      WHERE `fid`='1001' AND `type`=0;
  </code></pre>
  
  <blockquote>
    <p>result_1 = type0 ;</p>
  </blockquote>
  
  <pre><code>SELECT SUM(`quantity`) as type1 FROM `fruits_delivery`  
      WHERE `fid`='1001' AND `type`=1;
  </code></pre>
  
  <blockquote>
    <p>result_2 = type1 ;</p>
    
    <p>final_result = result_1 - result_2;</p>
  </blockquote>