shorting problem in query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chriskaza81
    New Member
    • Nov 2007
    • 52

    shorting problem in query

    i have a problem in a query like


    select field1, field2
    from table1
    order by field1 field1 contains countries (varchar2)


    the problem is that order by not shorting right , although i triyed everything..

    what could be the problem ? and is there any solutions?
  • deepuv04
    Recognized Expert New Member
    • Nov 2007
    • 227

    #2
    Originally posted by chriskaza81
    i have a problem in a query like


    select field1, field2
    from table1
    order by field1 field1 contains countries (varchar2)


    the problem is that order by not shorting right , although i triyed everything..

    what could be the problem ? and is there any solutions?
    hi,
    if you want to get values in some order then simply use the following query
    select field1, field2 from table1 order by field1

    if you want to get the values on some condition use where clause
    select field1, field2 from table1 where your_condition order by field1

    for more details on "Contains" visit the following link, where you can see some examples

    http://msdn.microsoft. com/en-us/library/ms187787.aspx

    Comment

    • ck9663
      Recognized Expert Specialist
      • Jun 2007
      • 2878

      #3
      Originally posted by chriskaza81
      i have a problem in a query like


      select field1, field2
      from table1
      order by field1 field1 contains countries (varchar2)


      the problem is that order by not shorting right , although i triyed everything..

      what could be the problem ? and is there any solutions?
      Could you post some sample data on your table1 and how you would want it sorted? Since your countries are just varchar(2), I am assuming it's a code of some sort. If you need it sorted by name, you might need to join it with the table with the country name on it.

      -- CK

      Comment

      • Delerna
        Recognized Expert Top Contributor
        • Jan 2008
        • 1134

        #4
        Originally posted by chriskaza81
        i have a problem in a query like


        select field1, field2
        from table1
        order by field1 field1 contains countries (varchar2)


        the problem is that order by not shorting right , although i triyed everything..

        what could be the problem ? and is there any solutions?
        also, be aware that text always sorts correctly for text (ascii values) but it dosn't always sort as we humans expect it to.

        Comment

        Working...