Solved

SQL sort values alphabetically then Numercially

Posted on 2009-05-18
2
431 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:afsfire
2 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 500 total points
Comment Utility
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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now