表:
purchase_stock_entry(id,purchase_party_id,bill_no,dt,product_id,qty,price,type)
purchase_party_name(purchase_party_id,name_shop)
我希望列中的输出为(bill_no,name_shop,sum(qty*price))
并加入这两个表
我也在尝试:
select p1.bill_no,p2.name_shop,p1.qty*p1.price as [Total],p1.dt from purchase_stock_entry
p1,purchase_party_name p2 where p1.purchase_party_id=p2.id
但总结我怎么做?
答案 0 :(得分:2)
SELECT bill_no, name_shop, SUM(qty * price) AS [total]
FROM purchase_stock_entry INNER JOIN purchase_party_name
ON purchase_stock_entry.purchase_party_id = purchase_party_name.purchase_party_id
GROUP BY bill_no, name_shop;
答案 1 :(得分:0)
请使用此,可以工作
SELECT p1.billno,p2.name_shop,sum(p1.price * p1.qty) 来自purchase_stock_entry p1,purchase_party_name p2 在哪里p1.purchase_party_id = p2.purchase_party_id