Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

Un aggregato potrebbe non essere visualizzato nell'elenco di set di un'istruzione UPDATE

Immagino che (come altri hanno sottolineato) non vuoi davvero un cartesiano su questo aggiornamento, quindi ho aggiunto un "id" alla query, quindi dovrai apportare alcune modifiche ma questo potrebbe portarti sulla strada giusta

;with temp as (
    select  a.id, SUM(a.pazartesi - b.kota) as newTotal
    from    [asgdb01].[dbo].[info] a join [asgdb01].[dbo].[kota] b 
          on a.id = b.id
    where   a.work_type='in' and a.name='alp' )
update  a
set     fm = t.newTotal
from    [asgdb01].[dbo].[info] a join temp t on a.id = t.id