Swapping Row & Column Positions

Gandolf

Registered User.
Local time
Today, 12:19
Joined
Jan 10, 2003
Messages
16
If you would like an easy problem, please answer this one for me... I have a query with 8 (or more) field names, just call them A, B, C, D, E, F, G, H, and a single row showing the totals from a table with the same field names.
I want a query with only 2 fields: one showing the field names and one showing their totals.
I set up a table with a field name ID and a listing of all the field names, but now I am stuck. Help me out please?
Feeling very rusty... Gandolf
 
I would opt for an SQL UNION query to solve this particular problem as in:

Code:
SELECT [A] AS [Field1], [B] AS [Field2] FROM [YourQuery]
UNION SELECT [C],[D] FROM [YourQuery]
UNION SELECT [E],[F] FROM [YourQuery]
UNION SELECT [G],[H] FROM [YourQuery]
 
Still trying to swap Columns & Rows

Thank you for the reply Fornation (Ian). I do not understand your solution. (Sorry)
Let me try a rephrase:
I have 8 fields. Each is a persons title.
My current query shows each field (title) and the sum of the number of times that title was selected from an input form.
I want to create a query with 2-fields.
One will be "Titles",
The other, their "Totals".
How do I convert the 8 field names and their sums, to 8 records showing the field name and corresponding sum?
Hope I'm not sounding to dense about this. Anyones help would be appreciated!
...Gandolf
 
Last edited:
Type in the SQL View of a new query, using the correct field names for A,B,C,etc.

SELECT "A" AS [Title], [A] AS [Total] FROM [YourQuery]
UNION
SELECT "B", FROM [YourQuery]
UNION
SELECT "C", [C] FROM [YourQuery]
UNION
SELECT "D", [D] FROM [YourQuery]
UNION
SELECT ....... etc
 
Awsome Swap!

Outstanding! Thank you Jon K !!!
The Code worked perfectly! ...grb

My Thanks to Ian too... it looks like almost the same code, but I couldn't make the logic leap until it was really spelled out. ...grb
 
Last edited:

Users who are viewing this thread

Back
Top Bottom