Ask a Question related to ASP Database, Design and Development.
-
Alpay Eno #1
sql SORT order not working on numbers?
Hello all... I'm using asp to get records from an access database, very
similar to the way datagrid would work. The title of each column in my table
is a link that alternates the sort order between ascending and descending...
my problem is that text WILL change its sort order just fine but nubers are
not always in order. ie: if sort order is ASC (ascending) I might see 2000,
234, 789 (should be ordered but its not). I'm guessing that ASP is handing
the string as a text string (?) and getting confused, is there a way to
force ASP into treating the string as numerals if this is the case? any
other ideas? Thanks so much.
here is one of my sql commands in case you want to see it. "sort" is a
variable containing the recordset to sort by depending on which link is
clicked. I hope I didn't confuse the whole issue because of a lack of
caffiene over here :)
strsql = "SELECT * FROM comments ORDER BY " & sort & " DESC"
Thanks of the help, much appreciated.
Eno
Alpay Eno Guest
-
ORDER BY (numbers and letters)
I've got a table of data that I want to sort by lot number. The lots are in the form of 1A, 1B, 2A and so on. Obviously, this is a text field. So... -
PHP Sort order definitions
I couldn't seem to find this in the docs or the web doing a quick search... When doing a sort($aRay, $flag) what is the definition for how the... -
Natural order sort
I've written a natural order comparison funtion for the String class. This was based on Martin Pool's "Natural Order String Comparison" which was... -
Sort order
Hi, I've a table with some rows. With 'select * from tab order by sp1' I've got the following: sp1 --- a1 a2 -
how to sort numbers in varchar2
I have a varchar2 column which stores characters as well as numbers in string such as '12345'. I would like to sort the column so that it orders... -
Mark Schupp #2
Re: sql SORT order not working on numbers?
What is the data type of the column containing the number?
--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
[email]mschupp@ielearning.com[/email]
[url]http://www.ielearning.com[/url]
714.637.9480 x17
"Alpay Eno" <eno@spamsux.com> wrote in message
news:MxfPa.5539$hY1.1399166@news4.srv.hcvlny.cv.ne t...table> Hello all... I'm using asp to get records from an access database, very
> similar to the way datagrid would work. The title of each column in mydescending...> is a link that alternates the sort order between ascending andare>
> my problem is that text WILL change its sort order just fine but nubers2000,> not always in order. ie: if sort order is ASC (ascending) I might see> 234, 789 (should be ordered but its not). I'm guessing that ASP is handing
> the string as a text string (?) and getting confused, is there a way to
> force ASP into treating the string as numerals if this is the case? any
> other ideas? Thanks so much.
>
> here is one of my sql commands in case you want to see it. "sort" is a
> variable containing the recordset to sort by depending on which link is
> clicked. I hope I didn't confuse the whole issue because of a lack of
> caffiene over here :)
> strsql = "SELECT * FROM comments ORDER BY " & sort & " DESC"
>
> Thanks of the help, much appreciated.
> Eno
>
>
>
Mark Schupp Guest
-
Aaron Bertrand - MVP #3
Re: sql SORT order not working on numbers?
> my problem is that text WILL change its sort order just fine but nubers
are2000,> not always in order. ie: if sort order is ASC (ascending) I might seeLooks like this "number" column is not numeric at all, but rather> 234, 789 (should be ordered but its not).
CHAR/VARCHAR.
Try
ORDER BY CONVERT(INT, thatColumn)
Or try making the column a numeric data type, if it holds numeric data.
Aaron Bertrand - MVP Guest



Reply With Quote

