Link to home
Start Free TrialLog in
Avatar of Ernesto
ErnestoFlag for Mexico

asked on

Achive an Update!

Please guys i need to achive an update to a table

update actividades1 set codigo= SUM(CAST(a.hrs as decimal(15,1))) from hrsh a, actividades b where  b.descripcion=a.disciplina and a.actividad=b.actividad

Open in new window


the error

An aggregate may not appear in the set list of an UPDATE statement.

Please you help me experts!
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

update a1
set codigo= cj1.hrs_sum
from actividades1 a1
cross join (
      select SUM(CAST(a.hrs as decimal(15,1))) as hrs_sum
      from hrsh a, actividades b
      where b.descripcion=a.disciplina and a.actividad=b.actividad
) as cj1
Avatar of opotapov
opotapov

update      actividades1
set            codigo= (
                        Select SUM(CAST(a.hrs as decimal(15,1)))
                        from      hrsh a, actividades b
                        where      b.descripcion=a.disciplina
                                    and
                                    a.actividad=b.actividad
                        )
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.