Results 1 to 3 of 3
  1. #1
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051

    Rows to extra column sql

    I have a table which holds:
    Idnumber (autonumber)
    Staffid (integer)
    classID (integer)

    Basically class 18 is taught by staff member 14


    Eg
    Staffid classid
    14 18
    13 18
    12 17
    2 11

    I am hoping to run a query to convert the data to

    ClassID
    STAFF1IF
    STAFF2ID




    Class 18 has first teacher 14 and second teacher 13 ( order not important)
    Classid staff1id staff2id
    18 14 13
    17 12
    11 2

    Can anyone help?

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Options:

    1. SQL like:
    Code:
    TRANSFORM Max(StaffID) AS MaxStaffID
    SELECT ClassID
    FROM Table1
    GROUP BY ClassID
    PIVOT "Staff" & DCount("*","Table1","ClassID=" & [ClassID] & " AND IDnumber<" & [IDnumber])+1;
    2. VBA - review http://allenbrowne.com/func-concat.html
    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
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Thank you so much. This worked brilliantly.

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

Similar Threads

  1. Simple Table Design Basics - Extra Column or Rows ?
    By Powermac in forum Database Design
    Replies: 15
    Last Post: 10-16-2020, 03:35 PM
  2. Replies: 1
    Last Post: 08-23-2019, 05:16 PM
  3. IIF Function - Returning Extra Rows
    By accessnewbie352 in forum Queries
    Replies: 5
    Last Post: 01-02-2015, 12:27 PM
  4. Importing Excel File - Getting 7 extra blank rows each import
    By eking002 in forum Import/Export Data
    Replies: 4
    Last Post: 06-13-2013, 09:15 AM
  5. Query. Extra column.
    By seweryng in forum Queries
    Replies: 1
    Last Post: 01-14-2011, 08:59 AM

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