Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Loop problem

Author  Topic 

FabioEinaus
Starting Member

41 Posts

Posted - 2006-12-11 : 11:35:13
Hi ppl!

I'd like to update the Consumido and ConsumidoHR fields with the sum of the Custo and Horas, on a Tarefa and ProjectID. (view the picture to see what i'm talking)



I want to do what i wrote on the pic but on all the Rows on ProjectosTrabalhos

Can someone help me?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-11 : 13:31:10
update x
set x.consumido = q.aa,
x.consumidohr = q.bb
from projectostarefas as x
inner join (select projecid, tarefa, sum(custo) as aa, sum(horas) as bb from ProjectosTrabalhos group by projecid, tarefa) q on q.projectid = x.projectid and q.tarefa = x.tarefa


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

FabioEinaus
Starting Member

41 Posts

Posted - 2006-12-12 : 07:43:49
Thanks for the reply!

It works!

thank you!

You are awesome

Go to Top of Page
   

- Advertisement -