我尝试使用此查询将一个表内容的总和更新为另一个表。
update c set c.amountwithoutvat = SUM(c.amountwithvat / 1.25),
c.profitamount=(SUM(rp.amountwithtvat / 1.25) - (ps.netpurchaseprice*rp.qtysold)),
c.profitpercent= ((SUM(c.amountwithvat / 1.25) - (ps.netpurchaseprice*c.qtysold)) / SUM(c.amountwithvat / 1.25)) * 100
from data.cashierdailysales c inner join receipts r on c.salesdate=r.RecDate
inner join data.receipt_productlines rp on r.seriesno=rp.seriesno
inner join product_supplier ps on ps.productid=rp.productid
inner join product_chain pc on pc.productid=ps.productid and pc.activesupplier=ps.supplierid
where c.salesdate between CONVERT(date,'20-02-2014',104) and CONVERT(date,'03-03-2014',104)
但是我得到了这个错误,
`an aggregate may not appear in the set list of an UPDATE statement.
当我最后使用group by时,
Incorrect syntax near the keyword 'group'