Subject Re: ORDER BY as number when not
Author Alexander V.Nevsky
--- In ib-support@yahoogroups.com, Paul Vinkenoog <paul@v...> wrote:
> 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.

Unfortunately this will work only if values in selected strings
will contain only digits. More general solution I think will be store
such a columns with leading spaces or add them on select using UDF.

Best regards, Alexander.