If you know that it will always be in the form of "name number", then you can add two columns, which are a section of the original column, and sort them instead of the original
eg.
SELECT foo2.foo,
Left(foo,InStr(foo," ")) AS foo_name,
CLng(IIf(InStr(foo," ")>0, Right(nz(foo,0),
Len(nz(foo,0))-InStr(nz(foo,0)," ")),"0")) AS foo_number
FROM foo2
ORDER BY Left(foo,InStr(foo," ")),
CLng(IIf(InStr(foo," ")>0, Right(nz(foo,0),
Len(nz(foo,0))-InStr(nz(foo,0)," ")),"0"));
(encoded and verified)
This should give you the following results:
foo foo_name foo_number
--- -------- ----------
Approved Approved
Point 2 Point 2
Point 10 Point 10
Point 11 Point 11
Point 21 Point 21
and sorting will work with the foo_number part.
source
share