sql query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • KOS

    sql query

    Hi
    I making a web page and
    I trying to sort a table fram access.

    table name: lopere
    colum1 name: name
    colum2 name: class

    in colum 1 i have the name of some people
    in colum 2 i have god, best and better.

    i want to sort first all that has "better" and then "best" and finaly
    "god".

    How do i write sql statment???

    Kjell
  • Big Time

    #2
    Re: sql query

    You could create a third field in the lopere table called "sort" or
    something like that. In the "sort" column, Assign "better" the number 1,
    "best" the number 2, "god" the number 3 and the in the SQL order by the
    sortcolumn

    i.e. SELECT name, class FROM lopere ORDER BY sort ASC

    "KOS" <makitaREMOVE@O NLINE.NO> wrote in message
    news:lolki01e0j jq8a02fpirlrrfg q4rnbg3i8@4ax.c om...[color=blue]
    > Hi
    > I making a web page and
    > I trying to sort a table fram access.
    >
    > table name: lopere
    > colum1 name: name
    > colum2 name: class
    >
    > in colum 1 i have the name of some people
    > in colum 2 i have god, best and better.
    >
    > i want to sort first all that has "better" and then "best" and finaly
    > "god".
    >
    > How do i write sql statment???
    >
    > Kjell[/color]


    Comment

    • fredg

      #3
      Re: sql query

      On Mon, 23 Aug 2004 22:44:25 +0200, KOS wrote:
      [color=blue]
      > Hi
      > I making a web page and
      > I trying to sort a table fram access.
      >
      > table name: lopere
      > colum1 name: name
      > colum2 name: class
      >
      > in colum 1 i have the name of some people
      > in colum 2 i have god, best and better.
      >
      > i want to sort first all that has "better" and then "best" and finaly
      > "god".
      >
      > How do i write sql statment???
      >
      > Kjell[/color]

      You cannot sort on that field directly, as you are not sorting
      according to alphabetic standards (a - z).
      Create another column:
      SortBy:IIf([Class] = "Better",1, IIf([Class]= "Best",2,3) )

      Sort on this column.
      --
      Fred
      Please only reply to this newsgroup.
      I do not reply to personal email.

      Comment

      • KOS

        #4
        Re: sql query

        On Mon, 23 Aug 2004 22:02:17 GMT, fredg <fgutkind@examp le.invalid>
        wrote:
        [color=blue]
        >On Mon, 23 Aug 2004 22:44:25 +0200, KOS wrote:
        >[color=green]
        >> Hi
        >> I making a web page and
        >> I trying to sort a table fram access.
        >>
        >> table name: lopere
        >> colum1 name: name
        >> colum2 name: class
        >>
        >> in colum 1 i have the name of some people
        >> in colum 2 i have god, best and better.
        >>
        >> i want to sort first all that has "better" and then "best" and finaly
        >> "god".
        >>
        >> How do i write sql statment???
        >>
        >> Kjell[/color]
        >
        >You cannot sort on that field directly, as you are not sorting
        >according to alphabetic standards (a - z).
        >Create another column:
        >SortBy:IIf([Class] = "Better",1, IIf([Class]= "Best",2,3) )
        >
        >Sort on this column.[/color]

        So there is no way that i can sort somthing without doing it accending
        or decending in SQL

        Comment

        • Pieter Linden

          #5
          Re: sql query

          > So there is no way that i can sort somthing without doing it accending[color=blue]
          > or decending in SQL[/color]

          No. Think about it. Access can sort numeric fields or text fields.
          How is a database supposed to somehow know that {"good", "better",
          "best"} is some kind of value scale? Well, short of you telling it.
          So either use IIF or create another table with your text values and
          corresponding numeric values, do the join, and sort on the numeric
          values from your table.

          Comment

          Working...