Combine multiple rows into one row with multiple columns

  • Thread starter Thread starter Elysia Larson
  • Start date Start date
E

Elysia Larson

Hi,

I have a table set up so that there are three columns: StudyID,
DrawDate, and Value. StudyID and DrawDate are the primary key. I
want to create a table from this one that has only one row for each
StudyID so that it would go from:

StudyID DrawDate Value

to

StudyID DrawDate1 Value1 DrawDate2 Value2 DrawDate3
Value3 etc.

Is there a way to do this?

Thanks,

Elysia
 
Elysia Larson said:
Hi,

I have a table set up so that there are three columns: StudyID,
DrawDate, and Value. StudyID and DrawDate are the primary key. I
want to create a table from this one that has only one row for each
StudyID so that it would go from:

StudyID DrawDate Value

to

StudyID DrawDate1 Value1 DrawDate2 Value2 DrawDate3
Value3 etc.

Is there a way to do this?

Thanks,

Elysia

How many DrawDate fields will be needed per record? You are denormalizing
your data, and it will probably cause problems in the long run. If you have
multiple DrawDates associated with a single StudyID, you need a one-to-many
relationship between two tables to represent that relationship.
 
Back
Top