How to sum with conditions on other columns
<p>me trying to get sum on deliveryqty with group by po number on other tables like this</p>

<pre><code>SELECT
  po.PONumber,
  po.PODate,
  po.customername,
  po.Description,
  SUM(spb.DeliveryQty)
FROM
  tb_po AS po
LEFT OUTER JOIN
  tb_spb AS spb ON po.PONumber = spb.PONumber
GROUP BY
  po.PONumber,
  po.Description
</code></pre>

<p>and mysql show data like this </p>

<pre><code>PONUMBER   podate      customername    description          deliveryqty
4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 1500 ML      810
4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 600 ML       810
4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  810
4600293487 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  800
4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 240 ML      1200
4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 330 ML      1200
</code></pre>

<p>what i try is data is summed based on po number &amp; material description not summed all qty just on po number like this :</p>

<pre><code>PONUMBER   podate      customername    description          deliveryqty
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 1500 ML      250
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 600 ML       440
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  120
    4600293487 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  800
    4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 240 ML      1200
    4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 330 ML         0
</code></pre>

<p>here's the table i used</p>

<p>tb_po</p>

<pre><code>PONUMBER   podate      customername    description          
4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 1500 ML      
4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 600 ML       
4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT
4600293487 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT 
4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 240 ML    
4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 330 ML      
</code></pre>

<p>tb_spb</p>

<pre><code>  PONUMBER    podate     customername    description          deliveryqty
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 1500 ML      125
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 1500 ML      125
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB 600 ML       440
    4600293473 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  120
    4600293487 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  400
    4600293487 04/04/2016 Balikpapan-CLUB AMDK CLUB GALON 19 LT  400
    4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 240 ML      1200
    4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 240 ML      1200
    4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 240 ML      1200
    4600293489 04/04/2016 Balikpapan-CLUB AMDK CLUB 330 ML         0
</code></pre>