>I have a table with a primary key field that contains data much like this:
>
>A100
>A1000
>A110
>A1100
>A124
>A1240
>
>I would like to sort this data so that:
>
>A100
>A110
>A124
>A1000
>A1100
>A1240
>
>How exactly do I do this? It must be right in front of my face... I just dont see it...
>
>Thanx,
>
>
>Mike
Well, if you would increase number of letters, say,
AB001
AB010
AB10203, etc. in addition to your A001, A1010, A213, it would be hard to create an index expression.
Anyway, what about:
Assuming 6 is the length of PK field:
index on padr(repl("1",len(alltrim(PK))),6,"0")+padr(PK,6,"0")
If it's not broken, fix it until it is.
My Blog