[thelist] Sorting with SQL

rudy rudy937 at rogers.com
Tue Sep 23 18:11:32 CDT 2003


> However when I sort by ascending order I get
>
>   ABC 10-3
>   ABC 1-2
>   ABC 3-6
>   ABC 4-5
>
> Is there a trick I can do to sort these (about 30) records in the
"correct"
> order.

yes

the trick is, pull out the numeric portion as a substring, convert it to
a numeric expression, and sort on that

if it's as simple as the examples you have just given -- namely, that the
numeric follows the first space, and is in turn followed by a dash -- then
it should be fairly strightforward

it would help to know which database you're using, because they all
have different string functions for finding a character and converting
a substring to a numeric

rudy



More information about the thelist mailing list