我需要将表A中的产品值乘以表b中的购买量,并将SUM写入表B中的列。
table a
--------
product
value
table b
--------
memberID
freuency of purchase of product
Sum of purchases
答案 0 :(得分:0)
我认为这样的事情应该有用,如果你有两个表之间的关系,比如两个表中的productID,或者类似于此,试试看
Select tA.ProductsValue * tB.TotalPurchases as TotalMoney , ProductID
From TableA ta
Join ( select Count(purchases) as TotalPurchases, productID
from tableB
Group by ProductID
) tB on tA.ProductID = tB.ProductID