By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,932 Members | 1,468 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,932 IT Pros & Developers. It's quick & easy.

Order by two sql server fields datalength and date

100+
P: 229
Hi, I order with datalength and that's fine.

Expand|Select|Wrap|Line Numbers
  1. 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
Expand|Select|Wrap|Line Numbers
  1. order by datalength(workingmethods) desc, JoinDate desc
Any pointers would be appreciated.
Thanks
Richard
Feb 1 '14 #1

✓ answered by zmbd

If all you are worried about is sorting then, provided the rest of your SQL is properly formed then:
Expand|Select|Wrap|Line Numbers
  1. 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.

Share this Question
Share on Google+
2 Replies


Expert 100+
P: 1,043
"This does not work".....
hmmm, maybe you do need:
Expand|Select|Wrap|Line Numbers
  1. order by JoinDate desc, datalength(workingmethods) desc, 
But it's a bit unclear when reading your post.... ;)
Feb 1 '14 #2

zmbd
Expert Mod 5K+
P: 5,397
If all you are worried about is sorting then, provided the rest of your SQL is properly formed then:
Expand|Select|Wrap|Line Numbers
  1. 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.
Feb 1 '14 #3

Post your reply

Sign in to post your reply or Sign up for a free account.