Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Stew312
Starting Member
6 Posts |
Posted - 2005-02-22 : 13:47:41
|
I have a 'value' field that clients would like to see ordered in a certain way. This fiend contains numbers 0-9, and a few random special characters. They need to see it ordered numbers first, 0-9, and then special characters following. Problem is that 'order by value asc' puts the special characters first, and 'order by value desc' puts the numbers in reverse order. Any easy way to go about doing this? Thanks. |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2005-02-22 : 13:49:21
|
| how about some sample data? Please make sure you put in enough different examples to cover all possibilities. - Jeff |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-02-22 : 13:53:33
|
this would probably do it...order by (case when left(<field>,1) like '[0-9]' then 1 when left(<field>,1) like '[a-zA-Z]' then 3 else 2 end) asc, <field> asc Corey "If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain |
 |
|
|
Stew312
Starting Member
6 Posts |
Posted - 2005-02-22 : 13:59:53
|
| Cool I'll check it out.. Data is pretty simple, here is most of whats in the field: 0,1,2,3,4,5,6,7,8,9,+,*,j,T,?.It can basically be any single character, they just want the #'s first, in ascending order. I'll try that idea from above, thanks.. |
 |
|
|
Stew312
Starting Member
6 Posts |
Posted - 2005-02-22 : 16:03:04
|
| worked awesome! thanks again.. |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-02-22 : 16:25:20
|
no problem Corey "If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain |
 |
|
|
|
|
|
|
|