Link to home
Start Free TrialLog in
Avatar of Morpheus7
Morpheus7

asked on

Moving data from one table structure to different table structure

Hi,

We currently have the following table with the following columns:

AnimalID OrderNo, TestA TestA_Result TestB TestB_Result TestC TestC_Result

I would like to be able to move the data to a table that has one row per test, as opposed to the current one where there is one row per animal
 Like so

AnimalID OrderNo   TestA        testAResult
12345        09890      TestA        Neg
12345        09890      TestC        Pos
12345        09890      TestC       IC

All fields are VARCHAR or CHAR

Any assistance would be appreciated

Thanks
Avatar of Phillip Burton
Phillip Burton

Select AnimalID, OrderNo, TestA, TestA_Result
From myTable
UNION ALL
Select AnimalID, OrderNo, TestB, TestB_Result
From myTable
UNION ALL
Select AnimalID, OrderNo, TestC, TestC_Result
From myTable
ASKER CERTIFIED SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial