Home Page
Articoli
Tips & Tricks
News
Forum
Archivio Forum
Blogs
Sondaggi
Rss
Video
Utenti
Chi Siamo
Contattaci
Username:
Password:
Login
Registrati ora!
Recupera Password
Home Page
Stanze Forum
SQL Server 2000/2005/2008, Express, Access, MySQL, Oracle
Traspossing rows to columns
domenica 14 ottobre 2007 - 10.17
Elenco Threads
Stanze Forum
Aggiungi ai Preferiti
Cerca nel forum
aleplgr
Profilo
| Junior Member
51
messaggi | Data Invio:
dom 14 ott 2007 - 10:17
Hi, excuses for writing in english, but maybe someone can help me. I've got a table of a test applied to patients in different dates:
PATID DATE ITEMa ITEMb ITEMc ITEMd
PATIENTID is the identification of the patient
DATE is the date the test took place, one patient may have many (up to 7) different dates
ITEMa...ITEMf are the points the patient took in the questions of the test.
So now there are many rows for each patient, one row for each date the test is applied.
I need to generate one table where each patient appears in only one row, and the DATE and ITEMs are new columns for each different DATE. For example if all the patients appear at most in 2 different dates, the resulting table should be like this:
PATID DATE1 ITEMa1 ITEMb1 ITEMc1 ITEMd1 DATE2 ITEMa2 ITEMb2 ITEMc2 ITEMd2
If all the patients had at most 3 different dates, at the right of ITEMd2 should appear
DATE3 ITEMa3 ITEMb3 ITEMc3 ITEMd3
and so on up to 7
lbenaglia
Profilo
| Guru
5.625
messaggi | Data Invio:
dom 14 ott 2007 - 12:26
>I need to generate one table where each patient appears in only
>one row, and the DATE and ITEMs are new columns for each different
>DATE.
Hi alex,
what DBMS are you using?
Ciao!
--
Lorenzo Benaglia
Microsoft MVP - SQL Server
http://blogs.dotnethell.it/lorenzo/
http://italy.mvps.org
aleplgr
Profilo
| Junior Member
51
messaggi | Data Invio:
dom 14 ott 2007 - 12:34
I'm using Borland InterBase 7.5 but I think (hope) this can be solved using an SQL query independently of the dbms, or if not independent at least with the standard sql...
Torna su
Stanze Forum
Elenco Threads
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?
Dopo esserti registrato potrai chiedere
aiuto sul nostro
Forum
oppure aiutare gli altri
Consulta le
Stanze
disponibili.
Registrati ora !