Results 1 to 3 of 3

Thread: [RESOLVED] Natural sort order in SQL Access query.

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    140

    Resolved [RESOLVED] Natural sort order in SQL Access query.

    How can i sort a column (APART=CHAR field) in an access table in natural sort order with this value:

    1
    10
    12
    PART
    14
    2
    3+4
    5
    6
    8
    9-10

    I want sort in this order:
    1
    2
    3+4
    5
    6
    8
    9-10
    12
    14
    PART

    I use "SELECT * FROM db ORDER BY APART+0" ... But not work...
    Please help.
    Thank you

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Natural sort order in SQL Access query.

    There isn't an easy way to do it, but you can get closer to what you want by using this:
    Code:
    "SELECT * FROM db ORDER BY Val(APART), APART"
    That will list the text-only ones first... the following might switch them to the end:
    Code:
    "SELECT * FROM db ORDER BY Val(APART)>0, Val(APART), APART"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2006
    Location
    Craiova, Romania
    Posts
    140

    Re: Natural sort order in SQL Access query.

    Thank you!!!
    Last edited by cliv; Sep 12th, 2013 at 06:29 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
  •  



Click Here to Expand Forum to Full Width