PDA

View Full Version : 'Order by'


andrebr
10-05-2006, 04:51 PM
Hi.
I got a problem with this code... :eek:


<%
Set rsTimer= Server.CreateObject("ADODB.Recordset")
strSQL = "SELECT * FROM Times WHERE CustID="&strID&" ORDER BY month ASC"
rsTimer.Open strSQL, strCon
%>

(The code is in ASP.)

The output is:
1,10,11,12,2,3,4,5,6,7,8,9

It should be:
1,2,3,4,5,6,7,8,9,10,11,12

Why?

guelphdad
10-05-2006, 07:21 PM
because your record type is in char or varchar format. Either change your format to tinyint or else use:
order by month + 0
which will force the ordering to believe your strings are numeric in nature.

andrebr
10-12-2006, 04:52 PM
Thanks guelphdad :thumbsup: