Article View: borland.public.interbase.sql
Article #918columns for 4 row values
From: aleplgr
Date: Sat, 21 Apr 2007 18:46
Date: Sat, 21 Apr 2007 18:46
31 lines
1987 bytes
1987 bytes
Hi! I'm trying to create columns of a new table from row values. Now I have one table which describes the applications of a test to patients, the test consists of 4 questions (items) the table looks like this: PatientID Date Items Points Date is the date the test took place, Items are the 4 questions (Item1, Item2, Item3 and Item4) and Points are the points that PatientID took in each item that date. And I need to create a new table that looks like this: PatientID Date Item1 Item2 Item3 Item4 a column for each item, so in a row I'll have for each PatientID the date the test took place and the points he got for each of the four items. I'm trying to do something like this: totpatients = select COUNT (PatientID) from mytable counter =0 WHILE counter < totpatients DO firstpatient = select MIN (PatientID) from mytable select Points from myTable (where Items=Item1 AND PatientID = firstpatient) into :t1 select Points from myTable where Items=Item2 AND PatientID = firstpatient) into :t2 . . insert into newTable( firstpatient, Date, t1, t2,t3,t4) values (PatientID, Date, :t1, :t2,:t3,:t4) Delete firstpatient from myTable counter ++ END While But this doesn't look good
Technical Details
Message-ID:
<462a5bf9$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,6369c00f5955a10,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: columns for 4 row values Newsgroups: borland.public.interbase.sql X-User-Info: 147.83.72.249 NNTP-Posting-Host: 207.105.83.66 Message-ID: <462a5bf9$1@newsgroups.borland.com> Date: 21 Apr 2007 11:46:17 -0700 X-Trace: newsgroups.borland.com 1177181177 207.105.83.66 (21 Apr 2007 11:46:17 -0700) Lines: 31 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail