Subject Sum of rows Alejandro Garcia 2007-04-15T08:56:25Z
Hi! I have a table of patients who executed a test, each test has 10 items and I have to generate a new column with the sum of 3 of those 10 items.
The original table columns are this: PatientID Date Items Points Tester.
Date is the date the test took place, a test is started and finished at the same date
Items are the 10 items of the test, one in each row of the table
Tester is the doctor that applied the test to the patient.
Points is the score that the patient got in that item, that date, applied by that tester.
A tester can apply the same test to the same patient the same day more than once.
Two different testers can apply the same test to the same patient the same date so that date one patient will have 2 scores for each item.

I need to create a table with this columns:
PatientID Date Tester SumPoints
(where SumPoints is the sum of 3 known items of the test, for example Item1, Item2 and Item3)

I thought of doing something like this:
find maxpat minpat
while minpat < maxpat
select minpat date
select minpat tester
select minpat item1
select minpat item2
select minpat item3
result= item1+item2+item3
add result to final table
find another tester for the same date and patient calculate result, add to final table
find another date for the same tester and patient calculate result add to final table
increment minpat

what do you think? could this work? is there a better way to do it?