Article View: borland.public.interbase.sql
Article #905Sum of rows
From: aleplgr
Date: Sun, 15 Apr 2007 09:54
Date: Sun, 15 Apr 2007 09:54
30 lines
2189 bytes
2189 bytes
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? Thanks in advance
Technical Details
Message-ID:
<4621e830$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,f48a4e6400e7b013,start X-Google-Attributes: gid114a0e,public X-Google-Language: ENGLISH,ASCII-7-bit From: "aleplgr" <aleplgr@yahoo.es> Sender: "aleplgr" <aleplgr@yahoo.es> Reply-To: "aleplgr" <aleplgr@yahoo.es> Subject: Sum of rows Newsgroups: borland.public.interbase.sql X-User-Info: 147.83.72.160 NNTP-Posting-Host: 207.105.83.66 Message-ID: <4621e830$1@newsgroups.borland.com> Date: 15 Apr 2007 01:54:08 -0800 X-Trace: newsgroups.borland.com 1176627248 207.105.83.66 (15 Apr 2007 01:54:08 -0800) Lines: 33 Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!212.101.4.254.MISMATCH!solnet.ch!solnet.ch!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail