New related comments
Number of comments in the last 48 hours
Fixing a broken GDB file
MAX() in an InterBase query delivers the smallest value
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Question:I run the following query (see box below) and it returns the expected results.
Then I want to retrieve only the max() value and it returns the smallest value instead. Why is that?
Answer:I looked into the problem and suspected that the ID field 'units_scenarios_id' is not a numerical field. Indeed it was defined as a varchar().
You can add +0 to force Interbase to treat it as a number or do a clean type cast as shown below:
select max(cast(FIELDNAME as integer))