Results 1 to 3 of 3
  1. #1
    TheSpecialist is offline Advanced Beginner
    Windows 8 Access 2010 64bit
    Join Date
    Jul 2015
    Location
    Georgia
    Posts
    47

    changing fields into colomns

    Hello group I have been working on this sql script but I need some assistance. How do I take the row below (Source Table) and make the fields into columns


    Ex. I would like to have columns the name Cash4Table---GaFiceTable---Yourtable---Your Date---Your Number
    My script looks like this and I want to know what do I need to do. Thank you

    This is how my information look now along with my sql script

    PARAMETERS [Enter Date:] DateTime, [Enter YourNumber:] IEEEDouble;
    SELECT "YourTable" AS SourceTable, YourDate, YourNumber
    FROM YourTable
    WHERE YourDate BETWEEN [Enter Date:]-1 AND [Enter Date:]+1
    UNION ALL
    SELECT "Cash4Table", YourDate, YourNumber
    FROM Cash4Table
    WHERE YourDate BETWEEN [Enter Date:]-1 AND [Enter Date:]+1
    UNION ALL
    SELECT "GAFiveTable", YourDate, YourNumber
    FROM GAFiveTable
    WHERE YourDate BETWEEN [Enter Date:]-1 AND [Enter Date:]+1
    UNION ALL SELECT "MoonPhaseTable", YourDate, YourNumber
    FROM MoonPhaseTable
    WHERE YourDate BETWEEN [Enter Date:]-4 AND [Enter Date:]+1
    ORDER BY SourceTable, YourDate;


    SourceTable
    Cash4Table
    Cash4Table
    Cash4Table
    Cash4Table
    Cash4Table
    Cash4Table
    GAFiveTable
    GAFiveTable
    GAFiveTable
    GAFiveTable
    GAFiveTable
    GAFiveTable
    MoonPhaseTable
    MoonPhaseTable
    MoonPhaseTable
    MoonPhaseTable
    MoonPhaseTable
    MoonPhaseTable
    YourTable
    YourTable
    YourTable
    YourTable
    YourTable
    YourTable

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Union queries will gather from different sources and put everything into rows, not columns. You need a cross tab query. Try the wizard, and if you require more columns than what it can handle, start with the max it allows, then open it in sql view and insert the rest. Not sure if there is a limit to columns in a cross tab.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    already asked and answered here

    https://www.accessforums.net/showthr...999#post318999

    and here

    http://www.access-programmers.co.uk/...d.php?t=286840

    If you are going to ask the same question again, have the courtesy to provide links to your previous threads on the same subject and explain why the answers provided did not meet your requirements so you don't get the same answers again

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

Similar Threads

  1. changing multiple fields type to double
    By neefbeef in forum Access
    Replies: 1
    Last Post: 12-07-2014, 03:20 AM
  2. Replies: 4
    Last Post: 02-27-2014, 03:39 PM
  3. Replies: 4
    Last Post: 03-05-2013, 09:03 AM
  4. Replies: 2
    Last Post: 10-19-2011, 03:21 AM
  5. Replies: 26
    Last Post: 02-21-2011, 12:04 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