Re: Convert CHAR to INTEGER in a SELECT statement
Posted in 1998
Gabor Heppes — — source: Informix-list mailing list archive (1991-1998)
Warren, You can add 0 (zero) to your field in the SQL statement to have it converted to a number, as in: select max(my_char_field + 0) from my_table where ... This should give you what you want. The performance penalty is that the engine will not be able to use any indexes you might have on your char field. Gabor PS: This works backwords as well, ie. my_num_field||"" will yield a char field. Warren van Niekerk wrote: > > Hi > > We have a CHAR(4) field in a table, which is storing integer values. Is > there a function to access this field as an INTEGER ? We want to find the > MAX() of the field, but 10 is less than 9 when using char fields, so it > always returns 9. > > TIA > Warren van Niekerk