| Author |
Topic |
|
progoal
Starting Member
5 Posts |
Posted - 2012-09-18 : 16:28:30
|
| hi guys i have a problem, i want to select numbers before letters in the same column,:FM0001AS003ER0005OJ001UG0002i want something like thatFM0001UG0002ER0005OJ001AS003can someone help me?thanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-18 : 16:33:28
|
| can you explain how OJ came before AS?if you had considered only number part for sorting why FM0001 etc are after AS003?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
progoal
Starting Member
5 Posts |
Posted - 2012-09-18 : 17:00:32
|
| can you explain how OJ came before AS?i dont want order by letters only by numbers so if oj came before doesn't matter.. only the number partif you had considered only number part for sorting why FM0001 etc are after AS003?sorry i made a confusion. ill edit thatbtw sorry my english:P |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-18 : 17:23:38
|
| still your ordering is not properhow will 1 come after 5?as per your explanation you should be getting below as outputOJ001FM0001UG0002AS003ER0005------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
progoal
Starting Member
5 Posts |
Posted - 2012-09-19 : 05:45:48
|
| yes maybe is that i mistake about "00" and "000" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-19 : 11:45:04
|
| so are you telling you dont know what you're after?confirm whats the exact output you want and basis for itthen we'll help with queries------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
progoal
Starting Member
5 Posts |
Posted - 2012-09-19 : 16:28:06
|
| i want a order by ASC only with numbers. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-20 : 11:47:41
|
| the what you can do is something likeORDER BY SUBSTRING(field,PATINDEX('%[0-9]%',Field),LEN(Field))*1 ASCi assume format is consistent ie always alphabets followed by numbers------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
progoal
Starting Member
5 Posts |
Posted - 2012-09-20 : 14:14:54
|
| thank u for reply i solved the problem..with order by LEN(field), substring(field, PATINDEX('%[0-9]%', field), LEN(field):) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-09-20 : 23:14:11
|
| oh so you wanted to consider length as wellyou had not specified it in your requirement------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|