Link to home
Start Free TrialLog in
Avatar of alosito
alosito

asked on

Wrong "order by" results

I have the following Perl code that takes the data from MySQL and sorts it:

$querystr = "select ID,Name,Description,PictureURL,InformationURL,Rate,10_Min,20_Min,Connect from $Table_Name order by 10_Min desc,Rate asc,Connect asc";
$sth = &sql($querystr);

For some reason the sorted results look like this (field 10_Min):

526
412
135
1342
125
95

Why is 1342 not on top of this list and what do I need to do to change in the code to have 1342 on top?



Avatar of Perl_Diver
Perl_Diver

it's ordered in ASCII order, not numeric order. But it's not perl, it's SQL that is ordering the data. I'm not sure of the proper SQL command though to order it numerically.
ASKER CERTIFIED SOLUTION
Avatar of DireOrbAnt
DireOrbAnt

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This worked for me:

select ID, Name, Description, PictureURL, InformationURL, Rate, cast(10_Min as integer), 20_Min, Connect
from $Table_Name
order by 10_Min desc, Rate asc, Connect asc