Sorting on two fields?

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

    #1

    Sorting on two fields?

    I have a table with two numeric fields in it. Neither field is indexed. I
    want to sort by the first field and _then_ by the second.

    For example:

    ID Key#

    1 200
    2 100
    2 200
    1 100

    After the query would yield:

    1 100
    1 200
    2 100
    2 200



    I can't figure out how to structure my query syntax to make this happen.
    Any ideas?

    thx

    --

    Robert Oschler


  • Sugapablo

    #2
    Re: Sorting on two fields?

    Robert Oschler wrote:[color=blue]
    > I have a table with two numeric fields in it. Neither field is indexed. I
    > want to sort by the first field and _then_ by the second.[/color]

    SELECT ID, Key# FROM tablename ORDER BY ID, Key#


    --
    Sugapablo :: russREMOVE@suga pablo.com
    http://www.sugapablo.com | ICQ:902845

    Comment

    • Sugapablo

      #3
      Re: Sorting on two fields?

      Robert Oschler wrote:[color=blue]
      > I have a table with two numeric fields in it. Neither field is indexed. I
      > want to sort by the first field and _then_ by the second.[/color]

      SELECT ID, Key# FROM tablename ORDER BY ID, Key#


      --
      Sugapablo :: russREMOVE@suga pablo.com
      http://www.sugapablo.com | ICQ:902845

      Comment

      Working...