473,614 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 28258
What is the data type of the column containing the number?

--
Mark Schupp
--
Head of Development
Integrity eLearning
Online Learning Solutions Provider
ms*****@ielearn ing.com
http://www.ielearning.com
714.637.9480 x17
"Alpay Eno" <en*@spamsux.co m> wrote in message
news:Mx******** ************@ne ws4.srv.hcvlny. cv.net...
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
3200
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 image2.jpg image3.jpg image4.jpg image5.jpg
19
2616
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 = "file2"; myArray = "file3"; myArray = "file4"; myArray = "file5";
11
1939
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 to the database. How can accomplish this task? Thanks!
7
7523
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 ----------- 0 1
21
3196
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 column. Once the array elements are split, what is the best way to sort them? Thank you. //populate data object with data from xml file. //Data is a comma delimited list of values var jsData = new Array(); jsData = {lib: "#field...
2
7762
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ˆ GNU_ GNU} GNU< I was expecting:
1
4117
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
2724
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 12345678,23456789,34567890... 2. check record-2 again record-1, check record-3 again record-2 & record-1 check record-4 again record-3 & record-2 & record-1 and so on... (if duplicated, drop it)
3
2263
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 CrewCodes are for instance: D5159 D1801 D337 D5276 When I just sort by ascending, it's all out of order. How would I do this?
0
8142
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8444
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7115
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6093
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5549
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4058
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4138
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2575
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1438
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.