Re: Convert CHAR to INTEGER in a SELECT statement
Posted in 1998
On 10 Oct 98 at 19:47, Warren van Niekerk wrote: > 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. I'm sure this is a little late, but I think there's a Relational Database Design course scheduled in both Rivonia and Cape Town this month... :-) Seriously, this is a fairly substantial problem from your perspective, as the ASCII sort order will always give you this problem. Why don't you just convert the column to an INT? Or is there some character data in the column? If there is, you may need to stick another column into the table for numeric sorts. Alternatively, you can stick the data into another table where your CHAR column is an INT. Feel free to give me a call if you're still stuck. -- Ciao, Billy /Group Managing Director, The West Solutions Group: http://www.west.co.za \\ Drivel @ http://www.west.co.za/tasteless/ / \\ "Granted, Mr Wheeler's ideas are stupid and unreasonable, but he does own the company and I / think we should go along with him..." \\________________________________________________________________________________________________