473,396 Members | 1,914 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

Jul 20 '05 #1
2 28248
What is the data type of the column containing the number?

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearning.com
http://www.ielearning.com
714.637.9480 x17
"Alpay Eno" <en*@spamsux.com> wrote in message
news:Mx********************@news4.srv.hcvlny.cv.ne t...
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

Jul 20 '05 #2
> 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).


Looks like this "number" column is not numeric at all, but rather
CHAR/VARCHAR.

Try
ORDER BY CONVERT(INT, thatColumn)

Or try making the column a numeric data type, if it holds numeric data.

Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: David | last post by:
sorry for the last post, itchy fingers. I'm having a bit of difficulty sorting images named in sequential numerical order. Here are the image names and how I need them sorted. image1.jpg...
19
by: David | last post by:
Hi all, A while back I asked how to sort an array of strings which would have numerals and I wanted to put them in sequential numerical order. For example: myArray = "file1"; myArray =...
11
by: Leon | last post by:
I have six textbox controls on my webform that allows the user to enter any numbers from 1 to 25 in any order. However, I would like to sort those numbers from least to greatest before sending them...
7
by: Steve Crawford | last post by:
I am suffering some sort order confusion. Given a database, "foo", with a single character(4) column of data left padded with spaces I get: select * from foo order by somechars; somechars...
21
by: yeti349 | last post by:
Hi, I'm using the following code to retrieve data from an xml file and populate a javascript array. The data is then displayed in html table form. I would like to then be able to sort by each...
2
by: adrian.chandler | last post by:
Hi all, I have been using letter and symbol codes such as GNU< GNU\ GNU} GNUˆ in an Access table. I was surprised to see that when the table was sorted on this field, the order is: GNUˆ...
1
by: aarklon | last post by:
Hi folks, this is the program implementing quicksort #include<stdio.h> #include<stdlib.h> #define swap(a,b){int t; t=a;a=b;b=t;} int partition(int,int,int); void quicksort(int,int,int);
4
by: Tony WONG | last post by:
i have a number of forms with fax numbers to come up into arrays and then combine to string. after that i design the flow 1. break the string to array now the string looks like this...
3
by: jmarcrum | last post by:
Hey everyone! I'm working in Access 2003 and need help with the 'order by' in a query. I have an CrewCode that includes a letter as well as numbers, and I want to sort by the numbers. The...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.