Sorting a field

  • You bet.  Thank you for the feedback.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Hi Jeff,

    I encountered a similar problem again, but the same method is not solving a problem.In this there is a table with decimal values and few character value, i have to take the decimal values and sort them and leave them if it is a character type. The column name is asset_tagprefix .

    SELECT

    * from _asset

    ORDER BY CASE

    WHEN asset_tagprefix LIKE '[^0-9]%'

    THEN asset_tagprefix

    ELSE STR(CAST(asset_tagprefix AS decimal(7,4)),20)

    END

     

    when i tried using the above query i got the following error message

    Arithmetic overflow error converting numeric to data type numeric.

    Kindly help.

     


    Kindest Regards,

    sree

  • You know the drill, Sree... "Show me the data".

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 16 through 17 (of 17 total)

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