Results 1 to 6 of 6
  1. #1
    rigglesbee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    3

    Transformation from Wide to Tall

    A B
    Bob 1, 2, 3
    Sue 2, 3, 4
    Jane 2



    And want

    A B
    Bob 1
    Bob 2
    Bob 3
    Sue 2
    Sue 3
    Sue 4
    Jane 2

    What would be the SQL code to create this?

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Is B field a multi-value or is that just a comma separated string? The first would be easy, the second is not.
    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
    rigglesbee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    3
    The B field is a comma separated field unfortunately

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    By comma separated field you mean just a typed text string?

    If the items were selected by a multi-select listbox or combobox then that is a multi-value field.

    If this is simply a text string, parsing the string to separate records can be complex because of the inconsistent structure, not every value is the same length. Can there be more than 3 items or even none?
    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.

  5. #5
    rigglesbee is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    3
    Correct. This is just a string. The real data is actually patch IDs, with varying lengths but will be comma delimited in a single cell.

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Since there is no way to know how many elements, a UNION query is not possible.

    Only approach I can see is VBA code writing records to a temp table, essentially building the structure should have started with.
    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.

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

Similar Threads

  1. Multiple columns with wide group header
    By jeh35 in forum Reports
    Replies: 3
    Last Post: 08-22-2013, 12:09 AM
  2. Replies: 7
    Last Post: 12-29-2010, 04:07 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