a.id c_id p_type paid date
1 6 FLOUR 100.00 2015-06-22
2 7 OIL 50.00 2015-06-21
3 6 FLOUR 242.00 2015-06-24
4 6 FLOUR 392.00 2015-06-26
5 7 OIL 200.00 2015-07-29
6 7 OIL 300.00 2015-07-25
我一直在努力,只選擇不同的表值的總和,我想如何選擇不同欄的總和不添加整個列
SELECT customer.first_name, customer.last_name, credit.quantity,
credit.date_supplied, credit.unit_price, credit.p_type,
ROUND(SUM(account.amount_paid))
AS amount_paid, account.date_paid FROM credit, customer
LEFT OUTER JOIN account
ON account.c_id = customer.c_id ;
我想要顯示的總和有產品類型的麪粉和油然後我只能得到表中所有金額的總和。我將不勝感激。
http://stackoverflow.com/questions/11782292/sumdistinct-based-on-other-columns – Shivam