Subject Help. Select Problem
Author German Terrazas Angulo
hi all,

I have a little problem to solve.

1. I have a table

(fieldname: varchar(150), fieldvalue: varchar(150)) =
('comerce num', '90')
('address', 'Yellow Street')
('foundationDate', '01/01/2001')
('comerce num', '200')
('address', 'Black Street')
('foundationDate', '01/01/2000')
('comerce num', '3000)
('address', 'Green Street')
('foundationDate', '01/01/2002')

2. I need to perform a query retrieving all files where fieldvalue > '90'.
So, you could use:

select *
from table
where fieldvalue > '90'

But it fails because it does not return ('comerce num', '200'), ('comerce
num', '3000). The problem is string comparisons ('90' is not less than
'200') in firebird.

3. One solution we have though is cast fieldvalue to int at query time.
That is (using free cast notation):

select *
from table
where cast(fieldvalue to integer) > cast ('90' to integer)

.... but... if you cast '01/01/2002' to int it returns an exception.

Any idea to solve this problem ?

thanks,
yerman