sql - Error: An aggregate may not appear UPDATE statement -


i trying update column of temp table using following query:

update t set t.consumedquantity  = sum(ma.quantity) @temptable t join defaultshopview dsv on dsv.operationid =@opid join myspec ms with(nolock) on ms.workrequest = dsv.workrequest join myactual ma with(nolock) on ma.specid = ms.specid  

but getting error:

an aggregate may not appear in set list of update statement.

how update values?

you can use this:

update t set t.consumedquantity  = (select sum(ma.quantity) @temptable             join defaultshopview dsv on dsv.operationid =@opid             join myspec ms with(nolock) on ms.workrequest = dsv.workrequest             join myactual ma with(nolock) on ma.specid = ms.specid )  @temptable t join defaultshopview dsv on dsv.operationid =@opid join myspec ms with(nolock) on ms.workrequest = dsv.workrequest join myactual ma with(nolock) on ma.specid = ms.specid  

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -