I need to convert some fields and data into a seperate table

J

JethroUK©

I need to convert some fields and data:


Pri Key CV JS MS - etc x 9

15 X X X
16 X X -
17 - X
18 X X X
19 X X X
20 X X X


into a seperate table:

Foreign Key Module Stat

15 CV X
15 JS X
15 MS X
16 CV X
16 JS X
16 MS -
deedaa
dee daa

Any ideas?
 
J

John Spencer

UNION queries are your friend.

SELECT [Pri Key] as FKey, "CV" as Module, CV as Stat
FROM [Your Table]
UNION ALL
SELECT [Pri Key], "JS" as Module, JS
FROM [Your Table]
UNION ALL
SELECT [Pri Key], "MS" as Module, MS
FROM [Your Table]
....
UNION ALL
SELECT [Pri Key], "X" as Module, X
FROM [Your Table]

That will normalize the data. Then you can either use the saved union query
as the source for an append or make table query or just use the union query
when you need the normalized data.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
 
J

JethroUK©

Great Thanks


John Spencer said:
UNION queries are your friend.

SELECT [Pri Key] as FKey, "CV" as Module, CV as Stat
FROM [Your Table]
UNION ALL
SELECT [Pri Key], "JS" as Module, JS
FROM [Your Table]
UNION ALL
SELECT [Pri Key], "MS" as Module, MS
FROM [Your Table]
...
UNION ALL
SELECT [Pri Key], "X" as Module, X
FROM [Your Table]

That will normalize the data. Then you can either use the saved union
query as the source for an append or make table query or just use the
union query when you need the normalized data.

John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County

JethroUK© said:
I need to convert some fields and data:


Pri Key CV JS MS - etc x 9
15 X X X
16 X X -
17 - X
18 X X X
19 X X X
20 X X X


into a seperate table:

Foreign Key Module Stat

15 CV X
15 JS X
15 MS X
16 CV X
16 JS X 16
MS -
deedaa
dee daa

Any ideas?
 

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

Similar Threads


Top