I'm not sure if this is something that is possible - or whether it's something simple I'm overlooking. ;-)
I've got a table TABLE1 with a SERIAL_NO field in it.
This contains a string value.
Sometimes this SERIAL_NO field contains a number - i.e. '1000', '2999' - and sometimes it contains a string - i.e. 'AA001', 'ZZ001'
Is there any means by which I can order the result set - so that the numbers come first (in numerical order), then the strings.
When I ORDER BY SERIAL_NO it clearly treats it as a string (as it is) and I get orderings like:
100
1001
200
299
300
999
Ideally I want these to be in numerical order, so that 1001 follows after 999.
But I can't simply CAST this field as a number - as sometimes it contains a string value.
So I want the ordering to be something like:
100
200
999
1001
AA001
ZZ001
How can I go about doing this?
Can it be done?
Thanks in advance.
Steve
I've got a table TABLE1 with a SERIAL_NO field in it.
This contains a string value.
Sometimes this SERIAL_NO field contains a number - i.e. '1000', '2999' - and sometimes it contains a string - i.e. 'AA001', 'ZZ001'
Is there any means by which I can order the result set - so that the numbers come first (in numerical order), then the strings.
When I ORDER BY SERIAL_NO it clearly treats it as a string (as it is) and I get orderings like:
100
1001
200
299
300
999
Ideally I want these to be in numerical order, so that 1001 follows after 999.
But I can't simply CAST this field as a number - as sometimes it contains a string value.
So I want the ordering to be something like:
100
200
999
1001
AA001
ZZ001
How can I go about doing this?
Can it be done?
Thanks in advance.
Steve