I want to group the record co_id in the following way

  • I want to group the record co_id in the following way

    co_id

    101

    102

    103

    1

    201

    202

    203

    2

    301

    302

    303

    3

    But i am getting it this order

    co_id

    1

    101

    102

    103

    2

    201

    202

    203

    3

    301

    302

    303"

  • looks like your co_id is char / varchar.

    as the ascii code for space (' ') (Ascii 32) is smaller than zero ('0') (Ascii 48), it will be ordered that way

    if you can alter the table structure, try adding another integer column and set the value of the column to your desired ordering sequence

  • Since it seems to be char or varchar, if field only stores numeric values, the following might give the results you want:

    select * from testid order by rtrim(co_id) + 'ZZZZZ'

    If it can contain alpha, this would have to be adjusted.

  • Thank You Very much ......

    It is working

    Saiju Thomas

     

  • Good Idea !

  • You're welcome.

    I'm glad it worked for you.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply