I have a VARCHAR field in a Firebird 2.0 table that can contain alphanumeric characters. I need to sort data on this field, sorting all values that contain only numbers as numbers, and sort all other values as 0. For example, if I have four values, "1", "2", "10", "string", I need to sort it as "string", "1", "2", "10". Default sort with string sorts as "1", "10", "2", "string".
I was thinking of CASTing the values to INTEGER, but I'm getting conversion error on strings, which is of course correct. How to work around this?