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.
| Author |
Topic |
|
CLages
Posting Yak Master
116 Posts |
Posted - 2005-01-26 : 04:43:31
|
| hihow to update the sum of several values from one table in a Record from the same tableex.Table planopla_code pla_valueDeb pla_valueCre 12 100 0 13 30 014 20 0 15 40 0 16 0 0i want to get the sum(pla_valueDeb) from plano where pla_code between 12 and 15and update this result in Pla_valueCre of the pla_code = 16the final result should be pla_code pla_valueDeb pla_valueCre 12 100 0 13 30 014 20 0 15 40 0 16 0 190 tksC. Lagesby the way i tried this and doesnt workupdate planoset pla_valueCre = Pla_valueCre + Select pla_valueDeb from plano where pla_code between 12 and 15WHERE pla_code = 16 |
|
|
CLages
Posting Yak Master
116 Posts |
Posted - 2005-01-26 : 04:59:13
|
| i have already fixedtks anywayUPDATE PLANOSET PLA_DEBMES = PLA_DEBMES + (SELECT sum( (pla_slddeb - pla_sldcre ) + (pla_debmes - pla_cremes) ) from plano where (pla_codigo BETWEEN 3000000000000 AND 3999999999999) and (pla_empresa = 01) )WHERE PLA_CODIGO = 2211100000100 and pla_empresa = 01 |
 |
|
|
|
|
|