make a table that transpose columns to rows in an access query

G

Guest

Can anyone tell me how to make a table that transpose columns to rows in an
access query? I don't want to have to send it excel, transpose it and then
re-import it to Access. I would like to beable to do it all in access.
Thanks for your help!!!
:)
MG
 
B

Brian Camire

To transpose columns to rows, you might use a UNION query.

For example, if you had a table with columns A and B that looked something
like this:

A, B
1, 2
3, 4,
5, 6

and you wanted to get a result that looked something like this:

Attribute, Value
A, 1
A, 3
A, 5
B, 2
B, 4
B, 6

you might use a query whose SQL looked something like this:

SELECT
"A" AS [Attribute],
[Your Table].[A] AS [Value]
FROM
[Your Table]
UNION ALL
"B" AS [Attribute],
[Your Table]. AS [Value]
FROM
[Your Table]

UNION ALL (unlike just UNION) will preserve duplicates. So, for example, if
you had two rows in your table that had the same value of A, you would get
two corresponding rows (instead of just one) in your result. Check the Help
for details.

Hope this helps.
 

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