Results 1 to 3 of 3
  1. #1
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243

    Query -- Sort two columns

    I want to sort the first column by the grant id (Numeric) then I want the second column (last name) to be sorted alpha in accordance with the grant ID assigned to that person

    For example:
    04-29 Albertson
    04-75 Berns
    04-37 Carson

    05-29 Andrews
    05-35 Bacon
    05-00 Castillo



    06-01 Anderson
    06-12 Beacon

    And so forth. How do I do this?

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    If I understand.....there is a column, with data that looks like "04-29" and a second column with last names. You want to sort first by the two chars to the left of the dash, and second by last name?

    Will the grant id always have 2 chars to the left of the dash or could it be 3 chars?

    Try:
    Code:
    SELECT GrantID, Last_Name FROM YourTable ORDER BY left([GrantID],2), Last_Name
    Change the names in blue to your table and field names.

  3. #3
    snowboarder234's Avatar
    snowboarder234 is offline Competent Performer
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    243
    Yes, to your question: the grant id will always have 2 characters to the left of the dash. Never 3 characters.

    Sorry, if I'm dense. But I don't understand the answer. I don't write code -- is that what you're suggesting? Or is what you've given me what I put in the first (grant ID) and second (last name) column?
    Click image for larger version. 

Name:	Sort_ID_LastName.jpg 
Views:	2 
Size:	110.1 KB 
ID:	10027

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

Similar Threads

  1. Replies: 2
    Last Post: 05-17-2012, 03:52 PM
  2. Select Query after Sort
    By kdilag in forum Queries
    Replies: 5
    Last Post: 01-17-2012, 09:50 AM
  3. Report will order/sort 4 columns but not 5. Why?
    By TomHolden in forum Reports
    Replies: 6
    Last Post: 12-17-2011, 04:25 PM
  4. sort query by two fields, populate one
    By Dee300 in forum Queries
    Replies: 3
    Last Post: 09-15-2011, 03:22 PM
  5. Sort Query
    By jice89 in forum Queries
    Replies: 3
    Last Post: 05-06-2011, 05:56 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