Subject Re: [ib-support] ORDER BY as number when not
Author Paul Vinkenoog
Hi Todd,

[ order by cast suggestion: ]

> Yes, tried that. no luck

OK, too bad. This one works however:

select cast ( my_char_column as <int or float type here> )
, ...
, ...
from mytable
order by 1

Or define computed columns for the casts and order on those columns
when you need to. If you need to do that often, add real numerical
columns and populate them in after insert/update triggers.

Greetoz,
Paul


>>> We have a table that has a number of different kinds of codes in
>>> it. Some are numbers and some are not, so the code itself is
>>> defined as a CHAR.
>>>
>>> Is it possible to order the data numerically in a select statement
>>> even when it isn't so the data comes out like:
>>>
>>> 1
>>> 2
>>> 3
>>> 11
>>>
>>> instead of
>>>
>>> 1
>>> 11
>>> 2
>>> 3