Order by two sql server fields datalength and date

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fran7
    New Member
    • Jul 2006
    • 229

    Order by two sql server fields datalength and date

    Hi, I order with datalength and that's fine.

    Code:
    order by datalength(workingmethods) desc,
    I was wondering if there is a way of combining with date members registered. The result being those newest members (JOINDATE) with the most data (WORKINGMETHODS ) being returned first in the results..


    This does not work
    Code:
    order by datalength(workingmethods) desc, JoinDate desc
    Any pointers would be appreciated.
    Thanks
    Richard
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    "This does not work".....
    hmmm, maybe you do need:
    Code:
    order by JoinDate desc, datalength(workingmethods) desc,
    But it's a bit unclear when reading your post.... ;)

    Comment

    • zmbd
      Recognized Expert Moderator Expert
      • Mar 2012
      • 5501

      #3
      If all you are worried about is sorting then, provided the rest of your SQL is properly formed then:
      Code:
      ORDER BY datalength(workingmethods) DESC, JOINDATE DESC;
      Should sort by the datalength() then the JOINDATE
      What I didnt' see was the closing semicolon ";"

      1) Please clarify if you are only attempting to sort on two field within the same table, or what it is that you are actually attempting to do

      2) Please post the entire SQL. All too often the SQL string is malformed. Spacing, square brackets and puncutation, and order of clauses are all importaint and can result in the best case what you want to see, simply return nothing, or can delete entire databases in the case of an action query.

      Comment

      Working...