Results 1 to 3 of 3
  1. #1
    NSearch is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    62

    Query Stacking Columns as Rows

    Thanks in advance for your help on this.



    I have a table with the following fields:

    Table_A

    Tracking_Number, Account_Number, Correct_Address_1, Correct_City, Correct_State, Correct_Zip, Incorrect_Address_1, Incorrect_City, Incorrect_State, Incorrect_Zip

    I would like to display the results like:

    Tracking_Number, Account_Number, Correct_Address_1, Correct_City, Correct_State, Correct_Zip
    Tracking_Number, Account_Number, Incorrect_Address_1, Incorrect_City, Incorrect_State, Incorrect_Zip

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Use a UNION query (UNION ALL to allow duplicate rows). There is no wizard or designer for UNION, must type or copy/paste into SQLView of query builder.

    SELECT Tracking_Number, Account_Number, Correct_Address_1 AS Address, Correct_City AS City, Correct_State AS State, Correct_Zip AS ZIP, "Correct" AS Src FROM Table_A
    UNION ALL SELECT Tracking_Number, Account_Number, Incorrect_Address_1, Incorrect_City, Incorrect_State, Incorrect_Zip, "Incorrect" FROM Table_A;
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    NSearch is offline Advanced Beginner
    Windows 10 Access 2007
    Join Date
    Mar 2019
    Posts
    62
    Quote Originally Posted by June7 View Post
    Use a UNION query (UNION ALL to allow duplicate rows). There is no wizard or designer for UNION, must type or copy/paste into SQLView of query builder.

    SELECT Tracking_Number, Account_Number, Correct_Address_1 AS Address, Correct_City AS City, Correct_State AS State, Correct_Zip AS ZIP, "Correct" AS Src FROM Table_A
    UNION ALL SELECT Tracking_Number, Account_Number, Incorrect_Address_1, Incorrect_City, Incorrect_State, Incorrect_Zip, "Incorrect" FROM Table_A;
    Perfect, thank you!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Query with two columns to Rows
    By MrDummy in forum Queries
    Replies: 3
    Last Post: 05-14-2016, 10:03 AM
  2. Replies: 3
    Last Post: 05-06-2015, 06:02 AM
  3. Inverting Columns and Rows in Query
    By jlclark4 in forum Queries
    Replies: 1
    Last Post: 05-28-2013, 12:00 PM
  4. Query to transpose Data in Columns to Rows
    By ace1259 in forum Access
    Replies: 2
    Last Post: 04-10-2012, 01:49 PM
  5. Showing Columns & Rows in Crosstab query
    By coach32 in forum Queries
    Replies: 6
    Last Post: 09-11-2011, 07:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums