Enrico <scotty@linuxtime.it> writes:
> the first record has valore=98 and totale=0 for the first time of
> the loop, but my first result of totale is -298 instead of +98.
Hmm, that's a bit hard to believe. Could we see the whole example
not just a fragment? Usually, when you can't understand the problem,
it's because you're looking in the wrong place --- so a partial
example is tough to debug.
regards, tom lane