Ok, I'm a little confused. Sounds like you need a funky sort order. First you need separate letters, and THEN the normal sort order. (A, AA, AB, AC, then B will be completely normal)
First simple sorting by alphabetical field
select SORTFIELD, OTHER, COLUMNS, IN-TABLE from MYTABLE order by SORTFIELD
But that is not what you want. The problem is that you never tell us where you want AAA. Does this happen after AA or after ZZ?
AAA After ZZ:
select SORTFIELD, OTHER, COLUMNS, IN-TABLE from MYTABLE order by LEN(SORTFIELD), SORTFIELD
AAA After AA (Before AB)
select SORTFIELD, OTHER, COLUMNS, IN-TABLE from MYTABLE order by case LEN(SORTFIELD) when 1 then 0 else 1 end , SORTFIELD
James curran
source share