Results 1 to 3 of 3

Thread: SQL ORDER BY Question URGENT...

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    Behind you...
    Posts
    88

    SQL ORDER BY Question URGENT...

    Mjello...

    I would like to order by the difference of two tables, but I does not seem like SQL supports this operation.
    I have a field lets say Field1 and another field Field2 and would like to order by the difference between these two fields: Field1 - Field2

    I'm hoping for an SQL Query a little like this:
    Code:
    Select * From TableName where Field1 > 10 ORDER BY (Field1 - Field2) DESC
    Help please...
    Enjoy...
    ----
    If something is hard to do then it aint worth doing!!

  2. #2
    Fanatic Member Slaine's Avatar
    Join Date
    Jul 2002
    Posts
    641
    Could you do the following.

    Code:
    Select *, (Field1 - Field2) As SortKey From TableName where Field1 > 10 ORDER BY SortKey DESC
    I've not tried this out but I think it should work.
    Martin J Wallace (Slaine)

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Nov 2001
    Location
    Behind you...
    Posts
    88
    Yes it works fine... Thanks...
    Enjoy...
    ----
    If something is hard to do then it aint worth doing!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width