Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 need help in sorting

Author  Topic 

rp54969
Starting Member

1 Post

Posted - 2008-12-17 : 02:25:42
I have an sequence it is a combination of numerics and alphanumeric.Some are in numerics only.For example

1,1A,35,2B,2A,46,29.
After Sorting i WANT AS
1,1A,2A,2B,29,35,46.

This is just example i given.Hope you got my requirement.The sequence is always start with Numeric only.Please help me in this .This is very urgent.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-17 : 02:28:12
[code]ORDER BY LEFT(Field,1)*1,SUBSTRING(Field,2,LEN(Field))[/code]
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-17 : 02:31:42
ORDER BY LEN(Col1), Col1



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

mattyblah
Starting Member

49 Posts

Posted - 2008-12-17 : 03:07:16
I've worked on something similar. The problem becomes when you have sequences like '01' and '2A3' and '2'. The solution was complicated and prone to errors. Good luck.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-12-17 : 03:19:04
You mean something like this?
http://weblogs.sqlteam.com/peterl/archive/2007/12/19/Algorithm-to-sort-strings-mixed-with-Alpha-and-Numeric-values.aspx



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -