[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

one more question MR.liviutudor or any Available expert on the qsl statement

Posted on 2006-03-21
12
Medium Priority
?
215 Views
Last Modified: 2010-05-18
i am doing "...order by cStr(partname)"
it works fine as string sorting can you please tell me what to do if i need to sort useing the ACS() or cLng what to do cause its not working
0
Comment
Question by:najixp
  • 7
  • 3
  • 2
12 Comments
 
LVL 6

Expert Comment

by:liviutudor
ID: 16249485
well, if partname is already a string/text datatype then you don't need the CStr(partname) -- you could simple say ...order by partname
similar, if the column you want to order by is a number, you don't need to use CLng() -- simply just order by <column name>
Last but not least: I gather you are using ACCESS?
0
 

Author Comment

by:najixp
ID: 16249576
you i am useing msacces but visual basic inteface
the fact is the column is a string/text datatype i want to sort it useing the ascii of the string useing the sql statement
0
 
LVL 4

Expert Comment

by:abbdan
ID: 16251360
Is the part name a number by any chance?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 6

Expert Comment

by:liviutudor
ID: 16256184
well, like i said, if the column is a string, you do not need the CStr() function and it will sort it in alphabetical order -- is this not what you want?
0
 
LVL 4

Expert Comment

by:abbdan
ID: 16257200
Numerical order being different from alphabetical order could be your problem.  Depending on which one you want you can use CLng or CStr in the order by section but that looks like what you've already done.
The ASC() of a character is the numerical code that represents the character.  I don't think you can ASC("WORD") and sort.

If you want a numerical sort of the query string use CLng as long as there are no non numerical characters.  If you have one partname in your list that has a non numerical character your stuck with alphabetical order and or would have to jump through major hoops to get whatever results your looking for.
0
 
LVL 4

Expert Comment

by:abbdan
ID: 16257239
Heres a crazy idea:

Bring in your Numerical first then bring in your NonNumerical and put them together with some kind of custom sorting routine.
     
0
 

Author Comment

by:najixp
ID: 16258152
hi i am back
all i need is to sort the string/text datatype column useing their ascii in sql statement
0
 
LVL 6

Expert Comment

by:liviutudor
ID: 16258480
what exactly do you mean by "using their ASCII"???? :O
alphabetical sort is sorting them in order of their ASCII code! And the ASCII code is such that the code for 'a' is smaller than the code for 'b' which is smaller than the code for 'c' and so on...
0
 
LVL 4

Expert Comment

by:abbdan
ID: 16258535
According to Wikipedia (http://en.wikipedia.org/wiki/ASCII) ASCII is the text representation of standard printable characters.  So based on wikipedia's definition of ascii you want a text string sort or alphabetical sort.  Simply use the following:

SQLQuery = "SELECT CStr(PartNumber) as MyStringPartNumber FROM YourTable
                    ORDER BY MyStringPartNumber"
0
 
LVL 4

Expert Comment

by:abbdan
ID: 16258648
Now.. if your wanting to sort by the numerical code representation of each character in each word of every record PartNumber... thats crazy man!!  But I dig it ya know.
To do that you would have to be able to seperate each character of each word, convert it to the ASCII code representation and perform the sort for each word based on each ASCII code in that word for all records.  I'm not sure you can do that with the limitations of SQL Query Language.  I also think that if you were successfull that it would be a monster from Planet X.  I don't think I really want to spend the time to figure that one out and so I yeild to those who have alot more time on their hands.  

Also,I think it would be impossible if all PartNumbers didn't have the same number of characters, however, I'm not positive of this.
0
 
LVL 4

Accepted Solution

by:
abbdan earned 750 total points
ID: 16258723
If all partnumbers had same number of characters I would seperate them all using the midstring function and then order them sequentially ie:
SELECT ASC(Mid(PartNumber,1,1)) as A, ASC(Mid(PartNumber,2,1)) as B... FROM MyTable
ORDER BY A, B...
0
 
LVL 4

Expert Comment

by:abbdan
ID: 16300145
Wow.. was not expecting that one to be the solution for you.  Glad you could use it.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Introduction to Processes
Screencast - Getting to Know the Pipeline

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question