1
Hello, I’m trying to update the product table using the average unit values of one year in the document table (where the notes enter) and the q instruction I’m using returns with error:
UPDATE DimProduto
SET PM = AVG(DimDocumento.Vu)
FROM DimProduto
INNER JOIN
DimDocumento
ON
DimProduto.ProdId = DimDocumento.ProdId
WHERE (DimDocumento.DtCadstr BETWEEN CONVERT(VARCHAR(10), DateAdd(mm, -12,GetDate()-1),3) AND CONVERT (VARCHAR(10),GETDATE()-1,3))
the mistake is:
Mensagem 157, Nível 15, Estado 1, Linha 175
Uma agregação pode não aparecer na lista de conjuntos de uma instrução UPDATE.
PM is the average price field of the Dimproduto table and Vu is the field with the unit value of the Dimdocumento table. I need to filter the period in a year to have more updated values in the comparisons. I appreciate any help.
Vlw Bruno, thank you for the reply. Swirled ok.
– mpaganuc
From what you’re saying, it seems to be the case mark an answer as accepted. Here we do not write "solved" in the question. If you have an answer that really helped you, mark it as accepted. If you came to the solution on your own, put in the solution as an answer. So content is more organized and easier to find in the future by other people with similar problems.
– Bruno Warmling