Skip to content
Advertisement

UPDATE and SET column row values by calculating values from antoher table

I have two tables:

products – which has UnitsSold(total/cumulative amount of sold products/item), and

sales – which has SoldQuantity (how many units sold per transaction)

The same unit could be sold many times, so we need to calculate how many times it sold from sales table which have SoldQuantity and show the result in UnitsSold, which will show how many items we sold in total per item.

I use this Query but it return some problems

#1111 – Invalid use of group function):

So which is the correct query to return the accurate results and solve this problem?

Advertisement

Answer

You need to aggregate before joining:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement