Results 1 to 3 of 3
  1. #1
    benJAMin14 is offline Novice
    Windows 10 Access 2016
    Join Date
    Jul 2019
    Posts
    12

    Want to sort data from a table from rows into columns please help.

    I have a table that has two records I care about for this. The first is a primary key. The second is a score for that primary key 1-5. There are many of these records. I would like to have a query that displays all of the 1's in a column with their primary keys displayed. Then all of the 2's in the next column with their primary keys displayed and so on. Maybe this is a crosstab query but I am not sure.

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,977
    To clarify, your table has two fields. An ID field and the Score field.
    Your suggestion would work for a crosstab query if you had at least 3 fields for the row heading, column heading and value.
    You need at least one more field for your row heading(s) then use score as column heading and ID as value,
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    You mean you have two 'fields' you care about.

    These are scores for what?

    The third field can be calculated. Consider:

    TRANSFORM First(Table1.ID) AS FirstOfID
    SELECT DCount("*","Table1","Score=" & [Score] & " AND ID < " & [ID])+1 AS GrpID
    FROM Table1
    GROUP BY DCount("*","Table1","Score=" & [Score] & " AND ID < " & [ID])+1
    PIVOT Table1.Score;
    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. Transpose Data from Rows to Columns
    By Crdmster in forum Queries
    Replies: 1
    Last Post: 08-08-2017, 02:18 PM
  2. Replies: 3
    Last Post: 05-06-2015, 06:02 AM
  3. Sort Columns in an excel worksheet and Pivot table
    By Jhail83 in forum Programming
    Replies: 3
    Last Post: 09-04-2013, 09:07 AM
  4. Replies: 6
    Last Post: 05-09-2013, 11:00 PM
  5. Table rows to columns
    By Rhino373 in forum Programming
    Replies: 5
    Last Post: 12-22-2011, 01:44 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