473,320 Members | 2,180 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,320 software developers and data experts.

Sorting numbers..

46
Hi guys..

I facing a troble here. Please help me.
I want to sort my database in ascending number.
Such as a series: 10, 100, 20, 30, 27.
Answer will be: 10, 100, 20, 27, 30.
But the answer i want is: 10, 20, 30, 27, 100.

How should i write the code??
Below is my code. Please take a look and correct for me.

Thank you very much..

Expand|Select|Wrap|Line Numbers
  1. Adodc.RecordSource = "select * from table order by totalTime;"
Jun 1 '07 #1
7 1675
Killer42
8,435 Expert 8TB
...
Expand|Select|Wrap|Line Numbers
  1. Adodc.RecordSource = "select * from table order by totalTime;"
That SQL looks fine. Why, do you have a problem with it?

Oops! Sorry, had to go back and re-read.

The problem is fairly obvious. They are being sorted as strings, not numbers. The field type must be Text. If it is going to hold numbers, change it to a numeric data type.

(If you think about it, the response you are getting is sorted into perfect alphabetic sequence).
Jun 1 '07 #2
coolminded
137 100+
Hi guys..

I facing a troble here. Please help me.
I want to sort my database in ascending number.
Such as a series: 10, 100, 20, 30, 27.
Answer will be: 10, 100, 20, 27, 30.
But the answer i want is: 10, 20, 30, 27, 100.

How should i write the code??
Below is my code. Please take a look and correct for me.

Thank you very much..

Expand|Select|Wrap|Line Numbers
  1. Adodc.RecordSource = "select * from table order by totalTime;"
you can use the function
to_number(field_name,999999)
it will give the solution u want
eg:
select to_number(field_name,999999) from table_name

plz do reply if this works or not
with regards
Jun 3 '07 #3
berry
46
you can use the function
to_number(field_name,999999)
it will give the solution u want
eg:
select to_number(field_name,999999) from table_name

plz do reply if this works or not
with regards
I had tried the function u taught. But it can't work.
The error shows is "FUNCTION TableName.to_number does not exist".
Anyway, thanks for your help.
Jun 4 '07 #4
berry
46
That SQL looks fine. Why, do you have a problem with it?

Oops! Sorry, had to go back and re-read.

The problem is fairly obvious. They are being sorted as strings, not numbers. The field type must be Text. If it is going to hold numbers, change it to a numeric data type.

(If you think about it, the response you are getting is sorted into perfect alphabetic sequence).

Thanks Killer42. I get it d. But I don't know what type I should assign for the hour and date that user key in. Please help me.
Jun 4 '07 #5
Killer42
8,435 Expert 8TB
Thanks Killer42. I get it d. But I don't know what type I should assign for the hour and date that user key in. Please help me.
What data are you actually storing in the fields? If it is a number, I would set the field type to Number. To determine the size, select the Field Size entry field, and hit F1 for information on which size can hold what values.
Jun 4 '07 #6
Killer42
8,435 Expert 8TB
I had tried the function u taught. But it can't work.
The error shows is "FUNCTION TableName.to_number does not exist".
I'm not familiar with ToNumber, but I expect the Val() function should work.

By the way, remember TheScripts also has an Access forum where you can probably get much better answers on any Access-related questions.
Jun 4 '07 #7
berry
46
What data are you actually storing in the fields? If it is a number, I would set the field type to Number. To determine the size, select the Field Size entry field, and hit F1 for information on which size can hold what values.
How if I want to store the date in format: 4 June 2007. There are number and character.
Jun 4 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Federico G. Babelis | last post by:
Hi All: I have this line of code, but the syntax check in VB.NET 2003 and also in VB.NET 2005 Beta 2 shows as unknown: Dim local4 As Byte Fixed(local4 = AddressOf dest(offset)) ...
22
by: mike | last post by:
If I had a date in the format "01-Jan-05" it does not sort properly with my sort routine: function compareDate(a,b) { var date_a = new Date(a); var date_b = new Date(b); if (date_a < date_b)...
7
by: Foodbank | last post by:
Hi everyone. I'm having trouble with this radix sorting program. I've gotten some of it coded except for the actual sorting :( The book I'm teaching myself with (Data Structures Using C and...
3
by: melanieab | last post by:
Hi, When you click on a column header to sort in ascending or descending order, numbers (and dates) aren't sorted correctly. It turns up like this: 1 10 11 2 3 4
9
by: Dylan Parry | last post by:
Hi folks, I have a database that contains records with IDs like "H1, H2, H3, ..., Hn" and these refer to local government policy numbers. For example, H1 might be "Housing Policy 1" and so on....
5
by: ^cypis^ vel. SQ9JTI | last post by:
Hi there, i have a problem. I prepared bucket sorting with reading values from file (data.txt) and saving to other file (aus.txt). Everything is good if we talk about reading and sorting, but...
6
by: carlos123 | last post by:
I have a programming assignement that i have been working on for quite some time now. I need your guys' help. My assignement is to great a table with data in it. and it will have a combobox and 2...
7
beacon
by: beacon | last post by:
I'm writing a program as an assignment that takes 5 sorting algorithms and and tests for the amount of time and the number of comparisons it takes to um, sort an array. I have run into some...
18
by: =?ISO-8859-1?Q?Ney_Andr=E9_de_Mello_Zunino?= | last post by:
Hello. It seems a year is all it takes for one's proficiency in C++ to become too rusty. Professionally, I've been away from the language (and from programming in general), but I still preserve...
5
by: lemlimlee | last post by:
hello, this is the task i need to do: For this task, you are to develop a Java program that allows a user to search or sort an array of numbers using an algorithm that the user chooses. The...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.