我怎么加在SQL上,所以它不会加倍,因为分组

时间:2019-11-12 02:44:30

标签: mysql sql phpmyadmin

当我运行程序时,数字的结果取而代之的是将数字合并,并使数字成许多结果。

SELECT pengiriman_supply.po_nomor
    , data_supplier.nama_supplier
    , data_barang.nama_barang,
((sum(pengiriman_supply.jumlah))-(ifnull(masuk.terima,0))) as total 
FROM pengiriman_supply INNER JOIN data_supplier ON pengiriman_supply.idsupplier = data_supplier.id_supplier 
INNER JOIN data_barang ON pengiriman_supply.idbarang = data_barang.idbarang 
left JOIN masuk on masuk.refrence = pengiriman_supply.po_nomor 
where pengiriman_supply.tanggal between date_sub(curdate(), interval 120 day) and curdate() 
group by pengiriman_supply.po_nomor
ORDER BY pengiriman_supply.po_nomor desc;

结果是这个 enter image description here

1 个答案:

答案 0 :(得分:0)

似乎您正在尝试获取每个sum()的{​​{1}}。让我们将其放在po number中,然后再将subquery放入要显示信息的表中。

join