Transpose with repeated data

G

Guest

Hi All,
I've seen all the answers to the transposing questions, but mine is a little
different. I actually want to do the reverse, I would like to take the row
data and convert to columns:

Currently:
PupilIDX, Set1,Set2,Set3,Set4
PupilIDY, Set1,Set2,Set3,Set4

I have over 800 rows to convert, doing this quickly would be highly
beneficial.

Many thanks for all your help, in advance

Wendy


Need:
PupilIDX, Set1
PupilIDX, Set2
PupilIDX, Set3
PupilIDX, Set4
PupilIDY, Set1
PupilIDY, Set2 etc.

I have
The PupilID needs to be repeated on each row for each pupil enrolled in a
class.
 
D

Duane Hookom

I think you could use a union query:

SELECT PupilID, Set1 as TheValue, 1 as TheNum
FROM tblNoNameGiven
UNION ALL
SELECT PupilID, Set2, 2
FROM tblNoNameGiven
UNION ALL
SELECT PupilID, Set3, 3
FROM tblNoNameGiven
UNION ALL
SELECT PupilID, Set4, 4
FROM tblNoNameGiven;
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top