Order By Problem-Help

  • The order by clause is affected by a special character , "(", in the column, which messes up the ordering sequence. The order by results I get from the below query:

    select MyColumn 1

    from MyTable

    order by MyColumn 1

    is:

    ka(e)

    ka(r)

    ka(u)

    kai

    The results needed is:

    ka(e)

    kai

    ka(r)

    ka(u)

    Is there anyway to get the desired results, which would mean getting an order by result not affected by the first bracket, "(" ?

    Much appreciated!

  • order by replace(MyColumn 1,'(','')

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537
  • select MyColumn

    from MyTable

    order by REPLACE(MyColumn,'(','')

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Old Hand, GilaMonster-Simply thank you!

Viewing 4 posts - 1 through 3 (of 3 total)

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