
Signature
Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com
>I have data in a field e.g.
> 1
[quoted text clipped - 8 lines]
> What I need is some way of sorting the so the numbers come first and in
> numeric order then the letter number combinations.
I might be being thick here but this does not appear to sort them as expected.
The Val part does put the numbers in the correct order but the alpha
numerics get a value of 0 so come first in the query. If I then try to do
the second order you are back to square one with 1,10,100 etc as the numeric
sort, and the alpha numerics are not in order eg B80 comes before B8
> Hi,
> you can first order by Val([MyField]) and then by [MyField]
[quoted text clipped - 11 lines]
> > What I need is some way of sorting the so the numbers come first and in
> > numeric order then the letter number combinations.
John Spencer (MVP) - 30 Jul 2005 00:12 GMT
Try
ORDER BY IsNumeric(MyField) Desc, Val(MyField), MyField
IsNumeric should return -1 (true) and 0 False.
Val will return the value and will still return zero for the non-numbers, but
they are forced to the second section by the order by criteria.
> I might be being thick here but this does not appear to sort them as expected.
> The Val part does put the numbers in the correct order but the alpha
[quoted text clipped - 22 lines]
> > > What I need is some way of sorting the so the numbers come first and in
> > > numeric order then the letter number combinations.