Solved

SQL sort values alphabetically then Numercially

Posted on 2009-05-18
2
478 Views
Last Modified: 2012-05-07
I have a table in a form that I want to show the values in ascending alphabetical order and then nemerical. currently if you sort alphbetically it places the numeric values first. how can I get it to put the alphbetic valuse first? Using MS SQL 2005
0
Comment
Question by:Bill Warren
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
ID: 24415055
select * from tablename
order by case when isnumeric(fieldname) = 1 then 2 else 1 end asc, fieldname asc
0
 
LVL 3

Expert Comment

by:EricKaplan
ID: 24517687
It's quite dependent on the values you wish to sort, you could use the mentioned query or use padding to make the number value evaluate as alphanumeric.

You could use a function to calculate and return a "sortable" value.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

688 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