473,385 Members | 1,856 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,385 software developers and data experts.

OrderBy question

Hello.

I am trying to sort my results via the account number field.

I am sorting in descending order but the kicker is, the account numbers can contain letters as well. For example:

123456ABC1

What I am seeing in my results is this for example: (remember in DESC order)

123456ABC
1222
111234DEF

I dont undestand how that '1222' could be right there. Any ideas on what is wrong or how to correct this?

Thanks
Apr 8 '08 #1
4 1202
amitpatel66
2,367 Expert 2GB
Try this

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT * FROM table_name ORDER BY REPLACE(TRANSLATE(UPPER(column_name),'ABCDEFGHIJKLMNOPQRSTUVWXYZ',' '),' ','')
  3.  
  4.  
Apr 8 '08 #2
It did not work. Please help.

Thanks for the try.
Apr 8 '08 #3
I think my problem is that this field I am trying to order by is a varchar and not truly numeric. This could be the cause.
Apr 8 '08 #4
amitpatel66
2,367 Expert 2GB
I think my problem is that this field I am trying to order by is a varchar and not truly numeric. This could be the cause.
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT col1,col2,col3 FROM
  3. (SELECT col1,col2,col3, REPLACE(TRANSLATE(UPPER(column_name),'ABCDEFGHIJKL  MNOPQRSTUVWXYZ',' '),' ','') num FROM table_name) ORDER BY num
  4.  
  5.  
Apr 9 '08 #5

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

Similar topics

6
by: P. Emigh | last post by:
By default in more recent versions, Access forms keep users' last sort request in the "orderby" property. That can slow things down considerably, especially when the last user has chosen a...
2
by: DFS | last post by:
Access97: I opened a report, then opened a small form that floats above it and lets you choose report fields to sort on (by issuing the OrderBy statement). Well, apparently OrderBy actually...
1
by: Fez | last post by:
I'm trying to use OrderBy in the property control on a form. The field I have is called id_number, field type is numeric, indexed, the form is reading from a table. The list is coming up...
2
by: Todd | last post by:
Hello, I'm curious if anyone knows of a way (if one exists) to tell a form (in Access 2002 VBA) to sort on an unbound column of a combo box on the form. Here's what I want to do: A combo box...
2
by: Dutchy | last post by:
Hi there, After spending several hours trying all I could imagine and search for in Google I gave up. In a continuous form I want to sort the choosen column by clicking the header (label) of...
1
by: fecket | last post by:
The following code is used in my db to change the sort order of the report to various fields. I want to take this one stage further and use maybe a Case Select to give 2 or 3 different options to...
2
by: tim otero | last post by:
I should be able to figure this one out, but it's late: I'm trying to sort a report by two fields. I can do it easily if I hard-code the fields. However, I want to get user input and store the...
7
by: pbd22 | last post by:
Hi. I really need some advice on fine-tuning a stored procedure that is the meat of the search logic on my site. Customers are allowed to save searches, which dumps the search logic in a table...
7
by: qwedster | last post by:
Guys! How to use OrderBy with TimeZoneInfo.GetSystemTimeZones() in C# 3.5 (vide Code snippet 1)? However, I got it in VB.NET 9 (vide Code snippet 2)! Code snippet 1: using System;
4
by: Marc Gravell | last post by:
Ah right - I just saw your explanation of "Source"; yes - I'd have 2 queries, then: switch(Source) { case "File": viewData.blah = (from t in database.Tags where t.FileCount != 0 orderby...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.